Answer the question
In order to leave comments, you need to log in
Where to enter the function if the result of $save in Angular $resource is 422 response (instead of 200)?
I call the standard $save method of ng-resource. If the response from the server is 200 , then everything is fine and we get into the then method . If the response is 422 (validation failed), then does not work at all.
How to be? Where to enter the function in case of error, when the response code is different from 200?
masterOrder.$save().then(function (data) {
if (data.$resolved == true) {
$scope.acceptSuccess = true;
alertOptions.content = data.flash.message;
alertOptions.type = data.flash.class;
$alert(alertOptions);
$anchorScroll();
} else {
alert('failed');
}
});
Answer the question
In order to leave comments, you need to log in
You need to improve knowledge on promises : then the second argument is the error handler. There is also a catch method that catches all errors in general.
True, I don’t know Angular, perhaps there are special curves there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question