I'm trying to have a nested reactive form.
When I try to display a nested array I get an error "Cannot find control with path: 'contact -> phone -> 0 -> number'"
This is my payload
{
"_id": "5ddb9fa8545eb65b5b28a471",
"contact": {
"addressLocation": {
"apartment": "34",
"balding": "43",
"street": "some street"
},
"iconImage": "",
"mail": "[email protected]",
"phone": [
{
"name": "ABC",
"number": "0548888888"
}
]
},
"content": "some content",
"title": "some title",
"type": "regular",
"userId": "5d96545b7d84d2201abc879",
"updatedAt": "2019-11-25T09:32:24.886Z"
}
This is my HTML
<form [formGroup]="formC" (ngSubmit)="onSubmit()">
<div [formGroupName]="'contact'">
<div [formGroupName]="'addressLocation'">
<input type="text" class="form-control" [formControlName]="'apartment'">
<input type="text" class="form-control" [formControlName]="'balding'" >
<input type="text" class="form-control" [formControlName]="'street'">
</div>
<input type="text" class="form-control" [formControlName]="'iconImage'" >
<input type="text" class="form-control" [formControlName]="'mail'">
<div [formArrayName]="'phone'">
<ul class="subjectList">
<li *ngFor="let item of phoneFormArray.controls; let i = index">
<div [formGroupName]="i">
<input type="text" class="form-control" [formControlName]="'name'">
<input type="text" class="form-control" [formControlName]="'number'">
</div>
</li>
</ul>
</div>
</div>
</form>
What am i missing?
Thanks