【发布时间】:2016-05-06 06:24:46
【问题描述】:
我使用 angular.js 作为前端,使用 node.js 作为后端,现在我正在调用下面在我本地主页的按钮单击事件中提到的 URL。
示例网址:
当我调用上面的 URL 时,它会在新窗口中显示登录页面,在我输入电子邮件和密码后,它会重定向到下面提到的另一个 URL
重定向网址:
https://localhost:3000/auth/localhost?code=8dacae52ee284db3dc776aa6d3563912
预期结果:
现在,我想从 angular.js 中的上述 URL 获取代码值“8dacae52ee284db3dc776aa6d3563912”。
HTML 代码:
<html ng-app='app' ng-controller='LoginController'>
<head>
</head>
<body>
<div class="container">
<div class="jumbotron">
<button type="button"
class="btn btn-primary btn-lg" ng-click="tokenLogin()">
New Login
</button>
</div>
</div>
<pre>{{ cleanData | json}}</pre>
</body>
</html>
控制器代码:
angular.module('app', [])
.controller('LoginController', ['$location','$window','$scope', '$filter', function($location,$window,$scope, $filter) {
$scope.tokenLogin = function() {
var url = 'https://localhost:3000/auth/authorize?response_type=code&client_id=abzefcbbkjajsdd&scope=userfetchit&redirect_uri=localhost&nonce=32324';
$window.open(url);
};
}]);
【问题讨论】: