嗨我想在角度中显示laravel(5)表单验证错误。 这是我的控制器:
.controller('formController', function($scope,DocParamData,$state,$http,CSRF_TOKEN) {
'use strict';
$scope.docParam = $state.current.name.split('.');
$scope.docParam = $scope.docParam[1];
// we will store all of our form data in this object
$scope.saveUser = function(user) {
$http.post('/auth/register', {
user:user,
_token:CSRF_TOKEN
}).success(function(v){
return user;
}).error(function(err) {
$scope.errors = err;
$scope.$apply();
return $scope.errors ;
});
};
$scope.getColumns = function(){
$http.get('/columns/user').
success(function(data, status, headers, config) {
$scope.user = data;
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
};
});
和我的观点(嵌套' form.html'在register.blade.php中):
<div ng-repeat="e in errors">{{e}}</div>
无论我做什么 - $ scope.errors都没有更新 - console.log显示$ scope.errors具有正确的数据但仅在控制器中