How to trigger Angular 2 input validation manually? How to trigger Angular 2 input validation manually? angular angular

How to trigger Angular 2 input validation manually?


You can update the validity of a formControl

form.controls['myControl'].updateValueAndValidity();


If you have template-driven form you can access form throw ViewChild decorator:

@ViewChild('myForm') public form: NgForm;

then, validate one field or the whole form group using method mentioned above:

this.form.controls.myControl.updateValueAndValidity();


I found this to be much better

this.myForm.markAllAsTouched();