I get list of data from server and i want to show them inside a list of spans as below:
Each row correspond to one item of list and note that I create this list with *ngFor as below:
this.myForm = this.fb.group({
person: this.fb.array([
this.fb.group({
name: [''],
address: ['']
})
])
})
<form [formGroup]="myForm">
<div formArrayName="person" *ngFor="let person of serverData; let personIndex = index">
<div [formGroupName]="personIndex">
<input formControlName="name"/>
<input formControlName="address"/>
</div>
</div>
</form>
After running this code the browser gives me this:
Error:
No value accessor for form control with path: 'person -> 0 -> name'
But I know that I should use myForm.controls.person.controls instead of serverData in for loop, but I want to have both list and controls together.
Should I use two for loops that one of them iterates over server data and the other one iterates over form controls or I should use another way?
