如何从Node服务器获取请求pathvariables值到AngularJS控制器

我想通过使用ExpressJS发送到节点服务器的链接,从电子邮件客户端(例如Gmail)中获取tokenpathvariables的值,然后在控制器( MyController )中使用该值。

服务器正在显示视图reset.ejs并将传递的token值作为parameter passing给它。

以下是上述情况的代码:

server.js(ExpressJS)

 app.get('/reset/:token', function (req, res) { User.findOne({ resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) { if (!user) { res.render('reset', { title: 'Foo in a Bar', token: req.params.token, invalidTokenMsg: "Password reset token is invalid or has expired" }); } else { res.render('reset', { title: 'Foo in a Bar', token: req.params.token, invalidTokenMsg: "Choose a strong password" }); } }); }); 

重置ejs(EJS)

 <!DOCTYPE html> <html lang="en" xmlns:ng="http://angularjs.org" id="ng-app" ng-app="myApp"> <!-- stuff inside head --> <head> </head> <body > <!-- stuff inside body--> </html> 

myapp.js(AngularJS)

 angular.module('myApp', []) .controller('MyController', ['$scope', function($scope) { //how to get the value of token here? }]); 

如何有人告诉我如何获得控制器中的token值?

理想情况下,请求调用必须来自控制器内部。 会不会是这样,

 angular.module('myApp', []) .controller('MyController', ['$scope', $http, function($scope) { $http.get('reset/:token',{token:'xyzabc'}).then(function(data){ }); }]); 

(或)如果令牌更像是一个全局对象,则可以使用$ provide.constant并注入其他控制器对象。