Answer the question
In order to leave comments, you need to log in
Cannot find control with name: '0'?
My form:
this.formGroup = this.fb.group({ list: this.fb.array([]) });
private addControl(): void {
(<FormArray>this.formGroup.controls['list']).push(new FormControl());
}
<form [formGroup]="formGroup" class="dialog_form" autocomplete="off">
<div class="dialog_form__row" formArrayName="list">
<app-dropdown-list-children
*ngFor="let dropdown of formGroup.get('list')['controls']; let i = index"
[controlIndex]="i"
[parentFormGroup]="formGroup"
></app-dropdown-list-children>
</form>
<div [formGroup]="parentFormGroup">
<div class="dropdown" [formGroupName]="controlIndex">
</div>
</div>
this.addControl();
Cannot find control with name: '0'?
<form [formGroup]="formGroup" class="dialog_form" autocomplete="off">
<div class="dialog_form__row" formArrayName="list">
<input type="text" [formControlName]="i" *ngFor="let dropdown of formGroup.get('list')['controls']; let i = index" /
</div>
</form>
Answer the question
In order to leave comments, you need to log in
Well, it turns out that inside the app-dropdown-list-children it looks for a control with the name 0 in the formGroup, and there is no such control, in the formGroup there is only a control with the name list, xs maybe you can not specify the formGroup inside this component, just throw the control , and specify it via [formControl]="control", not via index
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question