I just went through an angular-fullstack application and i came across this piece of code:
catch( function(err) {
err = err.data;
$scope.errors = {};
// Update validity of form fields that match the mongoose errors
angular.forEach(err.errors, function(error, field) {
form[field].$setValidity('mongoose', false);
$scope.errors[field] = error.message;
});
I understand the piece of code what it is trying to say but i want to know if suppose an error occur what exactly is passed to function(error, field). i unable to interpret what happens if error occurred. so that i'll able to know what is actually happening in this code
This piece of code is in a controller
Can anyone please explain the whole procedure with example?
errors, which is a map of field:error. Each error has a message.