I have chosen to use reactive forms for my form and I have a list of checkboxes to check, and I'm trying to use the FormArray
to do this, however when I call my function in my Ng for , I got this error. Is it possible to change the AbstractControl
type or do I have to modify the parameters of my array?
HTML
<tr style="list-style-type: none;" [formGroupName]="i" *ngFor="let engin of getControls() | appFilter: searchText; let i = index" >
<input type="checkbox" formControlName="checked" [(ngModel)]="engin.isSelected" #fEngins name="list_engins[]" value="{{engin.identifiant}}"
(change)="isAllSelected()"/>
<td>{{engin.num_facade}}</td>
<td>{{engin.num_immatriculation_ef}}</td>
</tr>
component.ts
getControls() {
return (this.form.get('engins') as FormArray).controls;
}
CodePudding user response:
try this
getControls(): FormArray {
return this.form.get('engins') as FormArray;
}
Alternative, you can modify your code with some trick to be:
get controls(): FormArray {
return this.form.get('engins') as FormArray;
}
and usage:
*ngFor="let engin of controls.control"