I want to manually set the EmployeeForm as Invalid from the .ts file. Here EmployeeForm is a Template driven form.
I have tried to do the following but it didn't work.
this.EmployeeForm.setErrors({ 'invalid': true });
error message says:
Property 'setErrors' does not exist on type 'NgForm'. Did you mean 'getError'?
The same code works when I use it with other forms which are Reactive forms
incorrect
instead ofinvalid
? – Alexisthis.EmployeeForm.controls.forEach(control => control.setErrors({'invalid':true}))
orsetErrors({'incorrect':true})
don't remember which one the good. – Alexis