angularjs – 如何从与angularjs的角度相等的“req.something”
发布时间:2020-12-17 18:08:06 所属栏目:安全 来源:网络整理
导读:我正在学习如何使用nodejs和passport设置身份验证的教程. ( http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local) 本教程让我使用ejs渲染模板并传入flash数据. 而不是这个,我想使用angularjs.我遇到问题的部分是获取闪存数据.
我正在学习如何使用nodejs和passport设置身份验证的教程. (
http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local)
本教程让我使用ejs渲染模板并传入flash数据. 而不是这个,我想使用angularjs.我遇到问题的部分是获取闪存数据.我知道如何使用模板和发送变量,但角度中的内容取代了下面代码中的“req.flash(‘signupMessage’)”? 这是教程显示的代码: app.get('/signup',function(req,res) { // render the page and pass in any flash data if it exists res.render('signup.ejs',{ message: req.flash('signupMessage') }); }); 这是我设置路线的代码 // public/js/appRoutes.js angular.module('appRoutes',[]).config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) { $routeProvider // show signup form .when('/signup',{ templateUrl: 'views/signup.html',controller: 'SignupController' }); $locationProvider.html5Mode(true); }]); 这是控制器: // public/js/controllers/SetupCtrl.js angular.module('SignupCtrl',[]).controller('SignupController',function($scope) { $scope.tagline = 'TEST'; }); 解决方法
这里回答了类似的问题:
What is the proper way to log in users using Angular & Express?
TLDR:发布的答案是以下链接,其中作者描述您需要将所有护照内容保留在服务器端,然后允许客户端(有角度的东西)请求有关会话的信息. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |