After following the provided tutorial, I successfully created an 'Organization' form that can include multiple 'Contact' groups. However, I encountered difficulties in extending this setup to allow each 'Contact' group to have its own set of 'Email' groups.
The tutorial offers comprehensive guidance on achieving your goal.
To implement the desired structure, consider the following steps:
https://i.sstatic.net/peW5d.png
Begin by setting up a component (e.g., `AppComponent`) where you define the root `FormGroup` as shown below named `trustForm`.
app.component.ts
// Code snippet for AppComponent
In this component, you will find methods to handle the root `FormArray` named `contracts` effectively.
Next, customize the HTML template for the `AppComponent` as demonstrated in the tutorial, ensuring to use the appropriate `FormArray` name.
Subsequently, create a separate component called `ContractComponent` to manage individual contracts within the 'Organization' form using a nested `FormArray` for `emails`.
contract.component.ts
// Code snippet for ContractComponent
Similarly, adjust the HTML template for the `ContractComponent` to accommodate the `emails` array and provide functionality for adding and removing email entries.
Lastly, finalize the setup by implementing an `EmailComponent` to specify the fields required for each email entry.
email.component.ts
// Code snippet for EmailComponent
Then, populate the HTML template for the `EmailComponent` with the necessary input fields such as 'Text' for emails.
You can access the complete example on Plunker here.
If you prefer a more modular approach where each component manages its functionality independently, review the advanced Plunker Example.
For those interested in template-driven forms, check out the insightful article on creating nested template-driven forms in Angular: