Home How to get a browser alert message with angularjs and nodemailer
Reply: 1

How to get a browser alert message with angularjs and nodemailer

James Brett
1#
James Brett Published in 2017-11-14 20:53:41Z

I am trying to get an alert with after sending an email with nodemailer and not just the json response. Here is what I have so far:

app.js (nodejswith nodemailermodule):

transporter.sendMail(mailOptions, (error) => {
if (error) {
  res.sendStatus(500)
} else {
  res.sendStatus(200)
}
transporter.close();
});

});

angularjs:

$http.post({
  url: '/contactUs',
  data: '',
}).then(
  function successCallback(response) {
    $scope.alert("Message Sent!!")
  },
  function errorCallback(response) {}
)
Jackie Benowitz
2#
Jackie Benowitz Reply to 2017-11-14 21:01:22Z

you'll need to just call alert("Message Sent") instead of $scope.alert("Message Sent").

If you want it to be angularized, you can inject $window and call $window.alert("Message Sent") which will make it easier on you if you're unit testing.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.365406 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO