【发布时间】:2015-11-03 19:41:10
【问题描述】:
我正在尝试从重置密码电子邮件中的链接中检索重置密码令牌。该链接使用我试图获取的令牌将用户发送回我的节点/角度应用程序。
Laravel API:电子邮件模板
<td class="content">
<a href="http://localhost:3000/reset-password?token={{$token}}">Reset Your Password</a>
</td>
Node/Angular 应用程序: ResetPassword.ejs 模板:我正在使用角度控制器:
<div ng-controller="resetPasswordCtrl">
...stuff
</div>
重置密码控制器:
'use strict';
angular
.module('myApp')
.controller('resetPasswordCtrl', ['$scope', '$routeParams', '$location', function($scope, $routeParams, $location) {
console.log('ROUTE PARAMS', $routeParams); //object with a bunch of getters/setters
console.log('ROUTE PARAMS', $routeParams.token); //undefined
console.log('Location', $location.search('token')); //LocationHashbangUrl
console.log('Location', $location.search().token); //true
console.log('Location', $location.search()['token']); //true
console.log('Route current params', $route); //empty route object
}]);
对于 LocationHashbangUrl ($location.search('token')),我知道我使用令牌获得了正确的 url,因为 $$absUrl 显示了它。
为什么我无法使用控制器中显示的方法之一检索 token 参数?
【问题讨论】:
-
只有
console.log($routeParams)你得到了什么? -
@Erazihel 请看上面的编辑
-
你能把你的路由器的代码贴出来吗?尝试使用
$route而不是$routeParams像这样console.log($route.current.params); -
@Erazihel 请参见上文
标签: javascript php angularjs node.js