我正在使用ui-router在角度应用程序中进行路由。在httpInterceptor中,我正在检查身份验证拒绝,如果找到一个,则转换到“登录”路由。一切看似正常,但即使登录按钮最初工作(在访问任何其他页面之前),在transitionTo触发之后,登录按钮的表单的ng-submit不会触发,就像控制器未加载一样,但没有错误。这是我用来转换的内容:
$stateProvider.state('login', {
url: '/login',
templateUrl: 'components/user/login.html',
controller: 'loginComponentCtrl as login',
data: {
title: 'Dashboard',
titleIcon: 'fa-tachometer',
noAuth: true
}
});
这是路线:
<form name="login-form" ng-submit="login.login()">
...
<button type="submit" ng-if="login.processing !== true">Login</button>
这是登录按钮设置,这并不奇怪。
(function() {
'use strict';
var app = angular.module('ctk.components.login', []);
app.controller('loginComponentCtrl', ['AuthenticationService', loginComponentCtrl]);
function loginComponentCtrl(AuthenticationService) {
var self = this;
self.processing = false;
self.login = function() {
self.processing = true;
AuthenticationService.login(self.username, self.password)
.then(function(success) {
}, function(failureReason) {
self.errorMessage = failureReason;
})
.finally(function() {
self.processing = false;
});
};
}
}());
最后,登录控制器
public
同样,登录页面在最初加载时工作正常,但在转换为上述代码段后却没有。刷新可以解决问题。知道这里可能会发生什么吗?