I am using Angular Reactive forms. My parent component has a form, an Add Form. Submit and Reset buttons. When I click on Add form it adds a child form called profile-form to the DOM. The profile-form has two fields First Name and Email. The idea is to reuse the profile-form component for any number of times, the add button is clicked. Each form needs to be validated and the parent form should know the validation status of each child form.
My parent form has this HTML to generate the child forms in a for loop.
<div *ngFor="let fg of formList.controls; let infoIndex = index">
<app-profile-form formControlName="fg" [formList]="formList"
[formIndex]="infoIndex"></app-profile-form>
</div>
When I look at the console, I seem to be getting an error that formControlName 'fg' is not found in formList.controls. How do I fix this mapping of formControls between my parent and child form, such that the validation works?
Lets try to analyze the form.
You expect below as the end value of the form
In the above we have
So in the form we have to have this structure for the form to work
Some other amendments will include
Changing
formListGroupDefSignUpForm
I have also made a few changes in your
ProfileFormComponentSee Demo