You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
I am trying to figure out how to display error messages from the server. For example if I try to save something and I get a response that the name is a duplicate (or any other server side validation failed)
Basically when the submit ajax is fired if I get a 422 i then want to loop through the returned errors and then set the appropriate control to an error and then display the message.
Something along the lines of below. It sets the control red and does all that, but I dont know how to get the message to display under the control (err[field] is the message). I have the errors returning as {field: message}
err => {
for ( const field in err) {
this.form.controls[field].setErrors({"error": err[field]});
}
}
The text was updated successfully, but these errors were encountered:
I am trying to figure out how to display error messages from the server. For example if I try to save something and I get a response that the name is a duplicate (or any other server side validation failed)
Basically when the submit ajax is fired if I get a 422 i then want to loop through the returned errors and then set the appropriate control to an error and then display the message.
Something along the lines of below. It sets the control red and does all that, but I dont know how to get the message to display under the control (err[field] is the message). I have the errors returning as {field: message}
The text was updated successfully, but these errors were encountered: