material
material copied to clipboard
[master] Error messages won't show with form.field.$dirty added to ng-messages.
The following won't show the error message, the objective is to prevent showing the error message for the first time (on load).
<md-input-container>
<label translate>Email Address *</label>
<input type="email" name="email" ng-model="user.email" placeholder="[email protected]" required autocomplete="off">
<div ng-messages="loginForm.email.$error && loginForm.email.$dirty">
<div ng-message="required">
<translate>Email address is required.</translate>
</div>
<div ng-message="email">
<translate>Invalid email address.</translate>
</div>
</div>
</md-input-container>
I think you can't use both $error and $dirty inside ng-messages. It should evaluate to key/value pair.
Please change it to:-
<div ng-messages="loginForm.email.$error" ng-if="loginFrom.email.$touched">
ok thanks, that works for me.