访问angular.js中的连接闪存信息
Access connect-flash messages in angular.js
我正在修改一些代码,这些代码以传统的非SPA页面加载为前提,并向用户显示connect flash中间件生成的flash消息。它通过传递一个在EJS文件中呈现的对象来实现这一点。
我的应用程序是棱角分明的,后端没有模板引擎,我希望避免使用模板引擎。我如何让angular意识到这些闪光信息?
上下文如下:passportjs在出现错误时重定向到/signup
// 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
}));
谢谢你的帮助!
我的解决方案是创建一个EJS页面,其唯一目的是提取连接闪存数据,并将浏览器重定向到指定的路由,数据附加为querystring。
// 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')});
});
重定向.ejs
<html>
<meta http-equiv="refresh" content="0;<% if (redirect_url) { %><%=redirect_url %><% } %>" />
</html>
角度控制器
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);
}
});
情况可能会更糟。
相关文章:
- 自动将目录结构从网页下载到闪存驱动器
- 当一次加载所有文件时,是否有来自阵列的10个随机闪存文件显示在页面上?(在javascript中)
- Javascript闪存卡脚本如何才能让它切换
- Javascript未将数据返回到AS3闪存
- 使用 Javascript 切换闪存
- 如何检查闪存文件是否停止使用 javascript
- 闪存 SWF 本地存储限制
- 如何使用 javascript 单击闪存对象
- 从远程闪存调用javascript函数
- 赢得 10 通用应用程序与科尔多瓦尝试加载闪存
- 如果未配置闪存,我该怎么办,那么在自动捕获图像上应该有一些错误消息
- 单击图像,打开闪存文件作为弹出窗口
- 在 JQuery 中动态创建闪存卡
- 谷歌浏览器禁用黄色输入表单字段(无闪存)
- 如何保护闪存视频不刷新?.
- 使用 TLS (SSL) 从闪存 v11+ 连接到 nodejs
- 如何调试 youtube 闪存嵌入的行为
- Javascript:如何从USB闪存驱动器读取文件和文件夹
- 访问angular.js中的连接闪存信息
- socke.io 无法连接到闪存插座