Reputation: 3914
I am developing my project with angular(4)
I want to make validation.
<input [(ngModel)]="someModel" required placeholder="some placeholder"/>
But it triggers immediately.
How can i trigger required only after input was changed?
Upvotes: 1
Views: 50
Reputation: 11000
Something like this?
<input [(ngModel)]="someModel" required #someModel='ngModel' placeholder="some placeholder"/>
<div [hidden]="someModel.valid || someModel.pristine">
Field is required
</div>
p.s. but you must have access to AbstractControl class.
Some other options might be someModel.dirty
or someModel.touched
, but according to your question, pristine
is what you are looking for.
Upvotes: 1