【发布时间】:2017-11-28 11:09:11
【问题描述】:
我正在使用带有 ejs 引擎的sailsJS,我想将用户重定向回带有消息的输入页面(验证错误......)。 我曾经在 PHP 中使用 laravel 轻松使用它(return redirect('dashboard')->with('status', 'Profile updated!');)
即:我需要重定向用户说这个网站不存在
find : function(req,res){
var id = req.param(íd');
Site.find(id).where({isDeleted : null })
.exec(function(err,siteFound){
if(err) console.log(err);
if(siteFound) {
return res.view('site/show', {
site : siteFound
});
} else {
return res.redirect('/site');
}
})
},
我在sails 文档中进行了搜索,但一无所获。这如何在 SailsJS 中执行?
谢谢
更新:我通过安装 sails-hook-flash 找到了我需要的东西。我需要的功能称为flash messages。
感谢您的帮助!
块引用
【问题讨论】:
-
您想在sails 视图/ejs 模板中使用
status变量吗? -
我希望能够传递我将在重定向视图中显示的自定义消息