I have the following form
in Angular created with FormBuilder
:
constructor(private fb: FormBuilder) {
this.myForm = fb.group({
To add upon what @ranakrunal9 said.
If you would like to use validators with addControl do the following:
this.myForm.addControl('newControl', new FormControl('', Validators.required));
Just don't forget to add the following import
import {FormControl} from "@angular/forms";
Reference to addControl: https://angular.io/api/forms/FormGroup#addControl
Reference to FormControl: https://angular.io/api/forms/FormControl