Validation rules have been set in JSON format and are stored within a factory service.
"inputname":{
"rule":{
"required":"required", "ng-minlength":"3", "ng-maxlength":"16"
},
"error":{
"required":"Name is required",
"minlength":"Name must have at least 3 characters",
"maxlength":"Name can have up to 16 characters"
}
},
The rules have been added to the input element using a custom directive with a compile function. As a result, form validation is now functioning correctly.
The goal now is to display any errors in a different section of the HTML.
To accomplish this, I would like to include <ng-messages>
in the HTML by retrieving error messages from a service in JSON format.
What steps should be taken to properly showcase these errors on the page?