You should use this code:
let listForm: any; var subFormGroup = new FormGroup({}); subFormGroup.addControl("Your Controll Name", new FormControl('',res["Required"] ? Validators.required : null)) listForm = this.builder.array([ subFormGroup ]); this.form.addControl("Your new ArrayControll Name", listForm);
When you have an array of objects, you can use this:
let listForm: any; var controlItems =[Your Object Array]; var subFormGroup = new FormGroup({}); Object.keys(controlItems).forEach(function(key){ subFormGroup.addControl(controlItems[key], new FormControl('',res["Required"] ? Validators.required : null)) }) listForm = this.builder.array([ subFormGroup ]); this.form.addControl("Your new ArrayControll Name", listForm);
source share