【发布时间】:2015-12-23 17:21:45
【问题描述】:
我正在使用这篇文章进行 AngularJS 身份验证:https://medium.com/opinionated-angularjs/techniques-for-authentication-in-angularjs-applications-7bbf0346acec#.y7nkgrxqo
在文章中,他们提出:
.controller('LoginController', function ($scope, $rootScope, AUTH_EVENTS, AuthService) {
$scope.credentials = {
username: '',
password: ''
};
$scope.login = function (credentials) {
AuthService.login(credentials).then(function (user) {
$rootScope.$broadcast(AUTH_EVENTS.loginSuccess);
$scope.setCurrentUser(user);
}, function () {
$rootScope.$broadcast(AUTH_EVENTS.loginFailed);
});
};
})
$scope.login 中的 .then 有两个用逗号分隔的函数 --- 这是什么意思?
【问题讨论】:
-
更新以反映您的评论
标签: javascript angularjs