I'm trying to push another formbuilder within a formarray but it gives me an error since I think there are no items in the array when initializing the code, hence there are no controls. The error is Property 'controls' does not exist on type 'AbstractControl' after the
(<FormArray>this.loanTypeForm.controls['frequency']).controls[index]
I'm using angular 2.0.0-beta.17
let settingsForm: FormArray = new FormArray([]);
(<FormArray>this.loanTypeForm.controls['frequency']).push(
this.formBuilder.group({
'name': [value, Validators.required],
'settings': settingsForm,
})
);
(<FormArray>this.loanTypeForm.controls['frequency']).controls[index].controls['settings'].push(
this.formBuilder.group({
'term': [null, Validators.required],
'eir': [null, Validators.required],
})
);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…