set form manually to invalid angular 2+

Viewed 46356

Is there a way to set a formGroup to invalid state manually?

I tried myForm.invalid = true; and also myForm.status = 'INVALID'

But invalid and status are const.

I dont want to mark a specific control as invalid. But the whole form.

2 Answers

Try this:

myForm.setErrors({ 'invalid': true });

Try this formData.form.controls['email'].setErrors({'incorrect': true});

Related