I'm trying to build a nested reactive form with formArray, but i get error: 'Cannot find control with path', it works fine if there is only one item in array, but if there is more that 1 it returns error. what am i doing wrong?
carPartCategories in ngfor is just data i get from server.
<form [formGroup]="updateEstimation">
<ng-container formArrayName="carPartStatus">
<ng-container *ngFor="let i of carPartCategories; let j = index;">
<ng-container [formGroupName]="j">
<div class="content-desc mt-4 mb-5">
<div class="row mt-4 parts-row align-items-center">
<div class="col-lg-2">
<span class="p-2 nusx">
{{i.carPartCategory}}
</span>
</div>
<div class="col-lg-3">
<span class="p-2 nusx">
{{i.carPartSubCategory}}
</span>
</div>
<div class="col-lg-2">
<span class="p-2 nusx">
<mat-form-field appearance="fill">
<mat-label>choose</mat-label>
<mat-select formControlName="status">
<mat-option>
test
</mat-option>
</mat-select>
</mat-form-field>
</span>
</div>
<div class="col-lg-2">
<span class="p-2 nusx">
X{{i.quantity}}
</span>
</div>
<div class="col-lg-2 price">
<input type="text" placeholder="price" class="form-control" formControlName="price">
</div>
</div>
</div>
<div class="comment mt-4 mb-5" *ngIf="i.comment">
<p class="mtav">comment</p>
<p class="nusx">{{i.comment}}</p>
</div>
<hr>
</ng-container>
</ng-container>
</ng-container>
</form>
.ts
this.updateEstimation = this.fb.group({
carPartStatus: new FormArray([
new FormGroup({
status: new FormControl(''),
price: new FormControl('')
})
])
});
StackBlitz: https://stackblitz.com/edit/angular-10-material-reactive-form-starter-bc7hd4?file=src/app/app.component.ts