html:
{{errormsg | i18next}}
controller:
loginModule.controller("loginController", ['$http', '$window', '$rootScope', '$scope', '$location', 'authenticationService', '$i18next', function($http, $window, $rootScope, $scope, $location, authenticationService, $i18next){
$scope.newclass = false;
$scope.errormsg = 'login.alertmsg';
$scope.login = function(){
if($scope.form_login.$invalid){
return false;
}else{
$scope.newclass = true;
$scope.dataloading = true;
authenticationService.login($scope.username, $scope.password,
function(response){
if(response.data.status_code == 200){
$window.location.href = 'view/home.html';
}else if(response.data.status_code == 500){
$scope.errormsg = 'error_code' + '.' +response.data.payload.error_code;
console.log($scope.errormsg);
$scope.dataloading = false;
$scope.newclass = false;
}
},
function(response){
$scope.dataloading = false;
$scope.newclass = false;
});
}
};
}]);
在登陆的地方我用了ngMessage,当表单验证错误的时候从json文件里面显示对应的错误信息。
现在需要在http请求500的时候,也显示从服务器收到对应的错误信息,已经将错误信息的key找到并且赋值给了$scope.errormsg。
现在的问题是如何使ngMessage那个p在500错误的时候显示出来
update
如果我不用ngMessage,只用ng-if的话可以显示表单验证信息和http错误信息,但是这样一来表单验证错误信息就不能动态显示了
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师