Issue
I have a FormGroup
with FormArray
control filled with FormGroup
instances
someForm = this.fb.group({
days: this.fb.array([
this.fb.group({
description: ['']
})
])
})
also, I have a getter for this array
get days(): FormArray {
return this.someForm.get('days') as FormArray;
}
when I'm trying to iterate through FormArray
and assign it to [formGroup]
directive, like shown in this article
<div *ngFor="let day of days.controls">
<ng-container [formGroup]="day">
...
I'm getting
error TS2740: Type 'AbstractControl' is missing the following properties from type 'FormGroup': controls, registerControl, addControl, removeControl, and 3 more.
Solution
I found a workaround in this article, to iterate through FormGroups
by index
like:
<div *ngFor="let day of days.controls; let i=index">
<ng-container [formGroupName]="i">
...
Answered By - Antony
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.