在angular.js中访问连接flash消息

我正在调整一些以传统非SPA页面加载为前提的代码,并向由连接闪存中间件生成的用户显示Flash消息。 它通过传递一个呈现在EJS文件中的对象来实现这一点。

我的应用程序是有angular度的,我没有在后端的模板引擎,并希望避免使用一个。 我怎样才能使angular度意识到这些Flash消息?

这里是上下文:passportjs错误redirect到/注册

// process the signup form app.post('/signup', passport.authenticate('local-signup', { successRedirect : '/profile', // redirect to the secure profile section failureRedirect : '/signup', // redirect back to the signup page if there is an error failureFlash : true // allow flash messages })); 

谢谢你的帮助!

我的解决scheme是创build一个EJS页面,其唯一目的是提取连接闪存数据,并将浏览器redirect到指定的路由,其数据作为查询string追加。

 // process the signup form app.post('/signup', passport.authenticate('local-signup', { successRedirect : '/profile', // redirect to the secure profile section failureRedirect : '/signup', // redirect back to the signup page if there is an error failureFlash : true // allow flash messages })); app.get('/signup', function(req, res) { // render the page and pass in any flash data if it exists res.render('redirect.ejs', {redirect_url: "/?route=/signup&message="+req.flash('signupMessage')}); }); 

redirect.ejs

 <html> <meta http-equiv="refresh" content="0;<% if (redirect_url) { %><%=redirect_url %><% } %>" /> </html> 

angular度控制器

 app.controller("Index", function ($scope, $route, $routeParams,$location) { var route= $routeParams.route, msg=$routeParams.message; if (route) { if ($location.$$search.route) { delete $location.$$search.route; $location.$$compose(); } console.log(route, msg); $location.path(route); } }); 

它本来会更糟。