I'm trying to display form array inside another formarray but it gives me an error, Cannot read property 'controls' of undefined
here is my code
addInventoryFormGroup() {
this.addInventoryForm = this.fb.group({
addInventoryFieldsList: this.fb.array([this.buildAddInventoryFields()]),
});
}
buildAddInventoryFields(): FormGroup {
return this.fb.group({
buildTableFields: this.fb.array([this.buildAddInventoryTableFields()]),
quantity: '',
section: '',
row: '',
})
}
buildAddInventoryTableFields(): FormGroup {
return this.fb.group({
unitCost: '',
faceValue: '',
})
}
get addInventoryFieldsList(): FormArray {
return <FormArray>this.addInventoryForm.get('addInventoryFieldsList');
}
here is my html code for it
<form [formGroup]="addInventoryForm">
<div class="reactive-form" formArrayName="addInventoryFieldsList" *ngFor="let address of addInventoryFieldsList.controls; let i = index;">
<div [formGroupName]="i">
<div formArrayName="buildTableFields" *ngFor="let fields of addInventoryFieldsList.controls.buildTableFields.controls; let x = index;">
<span [formGroupName]="x">ABC</span>
</div>
</div>
</div>
</form>
Please help me to fix this error
addInventoryFieldsListproperty?