I'm going to just sum up a couple of gotcha that I came across when using ng-messages . I believe that they will answer your question and help expand the use of ng-messages .
Multiple posts
Angular messages allow only one message by default to display only the first error message. You must tell ng messages to allow multiple messages.
Add ng-messages-multiple to your ng-messages directive
<div class="help-block" ng-messages-multiple ng-messages="claimForm.consigneeID.$error" role="alert">
Allow invalid values
Something else worth adding angular also does not always allow you to enter invalid values ββ(it will automatically clear the field when blurred).
If you want to resolve invalid data and display a message, you may need to update your input to inform the model of invalid values ββusing:
ng-model-options="{ allowInvalid: true}"
<input name="consigneeID" ng-model="coId" ng-model-options="{ allowInvalid: true}" type="number" ng-maxlength="5" ng-minlength="5" class="form-control input-sm" required>
Hide error messages. Display when loading a form.
If you want to hide messages when loading a form, you can use the $touched attribute in the form field.
<div class="help-block" ng-messages-multiple ng-show="claimForm.consigneeID.$touched" ng-messages="claimForm.consigneeID.$error" role="alert">
source share