Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if form control is valid in Angular programatically?

I need to check in the component (not in the template) if a control generated by formBuilder is valid. I tried:

if(this.miSpecialForm.controls.miName.dirty){
 console.log('Hi mom!');
}

but I get the error:

Property 'miName' does not exist on type '{ [key: string]: AbstractControl; }'
like image 418
user33276346 Avatar asked May 15 '17 06:05

user33276346


People also ask

Which of the following property is used to check if a form control is touched by the user or not?

The touched property is used to report that the control or the form is touched or not.


1 Answers

this.miSpecialForm.get('miName').valid
like image 129
Günter Zöchbauer Avatar answered Sep 20 '22 02:09

Günter Zöchbauer