如何处理$ resource angularjs的错误?
返回422错误,您可以检入第二张图片
我会在这里放两张图片,第一张是请求,第二张是请求后控制台上的错误。我无法找到解决方案。我看过google并没有。
请求:
http://gyazo.com/e1f123a957b9577bd8946d36762f44db
控制台错误:
http://gyazo.com/f2c0b086c58b96f89bb5019b82e1176c
我的restservice.js代码
app.factory('RestService', function($resource, $http) {
return {
customers: $resource(_CONFIG_REST + 'customers/:id'),
users: $resource(_CONFIG_REST + 'users/:id')
}
});
我的create.js
app.controller('customers.create', function($scope, $state, toastr, RestService) {
$scope.submit = function() {
RestService.customers.save($scope.data, function(response) {
toastr.success('The customer was added successfully');
}, function() {
toastr.error('An error has ocurred');
});
};
});