We have a component that has a dynamically built form. The code to add a control with validators might look like this:
var c = new FormControl(\'\', Validato
To add onto what @Delosdos has posted.
Set a validator for a control in the FormGroup:
this.myForm.controls['controlName'].setValidators([Validators.required])
Remove the validator from the control in the FormGroup:
this.myForm.controls['controlName'].clearValidators()
Update the FormGroup once you have run either of the above lines.
this.myForm.controls['controlName'].updateValueAndValidity()
This is an amazing way to programmatically set your form validation.