How to send req.flash messages from node to Angular.js

I am following the tutorial on setting up authentication with nodejs and passport ( http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local )

The tutorial has templates for rendering with ejs and passing information about flashes and error messages.

I like to use angularjs instead. I'm having trouble getting flash messages on the angular client side. I know how to use templates and send variables, but what in angular replaces "req.flash (" Message ") in the code below?

app.get('/signup', function(req, res) {    
  res.render('signup.ejs', { message: req.flash('signupMessage') });    
});

      

What is the equivalent or some other method to show our posts as req.flash from nodejs to angular

0


source to share


1 answer


Messages are req.flash

not intended for situations where you are using Angular or any other SPA framework, but for situations where you render HTML on the server and send it to the client on every request.

This will allow you to send the message only once when you start your Angular application or when you click Refresh in your browser, but not when you are using it.



For SPA like Angular you need to use AJAX or WebSocket or SSE etc. to send data from the server to the client about errors.

+1


source







All Articles