DEV Community

Discussion on: A case for extending Angular Forms

Collapse
 
alindberg profile image
alindberg

I am trying to extend AbstractControl to add a metaData structure to keep information about the controls (FormControl, FormArray ...) that could be used to manage not only the controls, but build the necessary forms for input.

Many of the 'dynamic' Reactive Form examples use an array of structures that is then used to build the FormGroup. The examples then pass this array of data along with the FormGroup structure to then build the input forms. This works if everything is static, but add a FormArray or generate a FormGroup on the fly and things quickly become interesting when trying to keep the data structure in sync with the FormGroup structured.

What I would prefer is a metadata element built into AbstractControl with the necessary getter() and setter() (or added to the constructor) that could then carry information on how to build that specific form control. This would be much like the 'data' element available in @angular/router.

This general concept has had quite a bit of traffic on githuib/angular/angular it does not seem to me, any forward progress.

Does your example given here, have a home on github or some other repo to use an example?

Collapse
 
digitalcrafting profile image
DigitalCrafting • Edited

Hi, first of all, sorry for the delayed answer. Yes, there is a github repo here, it's also linked in the following articles in which I provide an example of how to actually add your own functionality.