Gibt es eine Möglichkeit, eine FormGroup automatisch aus einem Modell zu erstellen? Wenn ich habe ein Modell mit mehreren Eigenschaften:Model Driven/Reactive Forms: Automatische Zuordnung von Model zu FormGroup?
Modell: Person
firstName: string,
lastName: string,
street: string
country: string
....
und ich möchte eine einfache FormGroup aus ihm heraus erzeugen:
Form: FormGroup
firstName: FormControl,
lastName: FormControl,
street: FormControl,
country: FormControl
....
Es scheint mir "schmutzig" zu sein, für jede Eigenschaft im Modell explizit ein FormControl/FormGroup/FormArray zu definieren:
formBuilder.group({
firstName: person.firstName,
lastName: person.lastName,
street: person.street,
country: person.country,
...
});
Jedes Mal, wenn sich die API vom Backend ändert, muss ich das Modell und das Formular-Mapping anpassen. Gibt es einen Generator, der mir hilft, das Mapping/Erstellen einer FormGroup zu automatisieren?