var app = angular.module('login', []);
app.controller('LoginController', ['$scope', '$http', function
($scope, $http) {
this.error='test';
this.submitForm = function () {
var params = $("#loginForms").serialize();
$http({
method: 'POST',
url: '/admin/doLogin',
data: params,
}).then(function (response) {
// this callback will be called asynchronously
// when the response is available
}, function (response) {
$scope.error = response
console.log(response.status)
if (response.status == 404) {
this.error = "Page not found";
}
});
}
}]);
我正在尝试在进程中设置错误消息并将其绑定到视图
<div id="container" ng-controller="LoginController as lm" >
<br>
<div class="error" >{{lm.error}}</div>
</div>
我正在尝试更改承诺拒绝事件中的错误变量。这不起作用,请帮助