I've been tackling a challenging task involving a dynamic Form in Angular where an array needs to be nested within another array.
However, I've encountered an issue with my form that throws the following error:
[Cannot find control with path: 'gruppen -> 0 -> prueffolge'][1] Outlined below is the object structure I'm working with:
"pruefplanTemplate": {
"gruppen": [
"prueffolge": 100,
"name": "test",
"pruefungen": [
"..": "",
"..": ""
]
]
}
This is my code snippet: Component:
import { Component, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-pruefplan-template',
templateUrl: './pruefplan-template.component.html',
styleUrls: ['./pruefplan-template.component.scss']
})
export class PruefplanTemplateComponent implements OnInit {
// Code logic here
}
Template:
<h3>Prüfplan erstellen:</h3>
<p>{{this.gruppen.length}}</p>
// HTML template structure here
Model:
export interface PruefplanTemplate {
gruppen: Gruppe[];
}
export interface Gruppe {
// Interface definition
}
export interface Pruefung {
// Interface definition
}
I could use some guidance from those more experienced with FormArray!
Appreciate your assistance! [1]: https://i.sstatic.net/hEAGL.png