0
我在引发异常后向用户显示消息时遇到问题。 我正在做的是试图以无效的用户身份登录。在这种情况下,服务器返回我401和消息“错误的用户名和密码组合”AngularJs中的用户页面上未显示错误消息
在我的控制,我的预成型这样的:
class LoginOnlineUserController {
constructor($state, AuthenticationService, LoginOnlineUserService) {
this.$state = $state;
this.AuthenticationService = AuthenticationService;
this.LoginOnlineUserService = LoginOnlineUserService;
this.username = null;
this.password = null;
}
login() {
let self = this;
this.LoginOnlineUserService.login({
username: this.username,
password: this.password
}).then(function(data) {
self.AuthenticationService.login(data.jwtToken);
if(self.AuthenticationService.isAuthenticated()) {
self.$state.go("hrTesting");
}
}).catch(function(msg) {
//alert(msg.data);
self.error = msg.data;
});
}
}
export default LoginOnlineUserController;
如果功能isAuthenticated()
被预制好,令牌响应,不是给该令牌给用户。 如果发生异常而不是进入catch块并在客户端页面上写入消息。
我使用NG-如果此:
<div ng-if="self.error" class="alert alert-danger">{{self.error}}</div>
但邮件永远不会显示。当我尝试提醒异常消息时,我可以清楚地看到它,但在用户页面上不存在错误消息。 有人看到我在这里做错了吗?