Is it in theory possible to add a new FormGroup to the form controls via 
input?


For instance to add values, via a form input, to an existing array I can 
use (click)="addAddress()" in the html where addAddress is defined in the 
component.ts to update values in an array in the form AppComponent as in 
this full working example here: https://embed.plnkr.co/sUjE1ULYhfDHLNBw2sRv/
1 <https://embed.plnkr.co/sUjE1ULYhfDHLNBw2sRv/>



I would like to know(if feasible) how to add a completely new FormGroup via 
form input. 

So taking the case of the example above...


Rather than adding to an array of addresses like this:

http://pastebin.com/GbgL9ATC


Each time an address is added a new FormGroup is created where the user 
adds the FormGroupName for each via form input to end up with something 
like this:

http://pastebin.com/mV8U2kV3


*(In the case of the example I appreciate if you wanted the user to be able 
to submit a ‘type’ of address it could more easily be done adding 'type' as 
a FormControl within the addresses array but I'm just using the example as 
a vehicle to ask how you can add a new FormGroup to the form controls via 
input. )*


I did begin to adapt the original example and added a few questions where 
I'm unsure:

https://plnkr.co/edit/HO5WWvZZMotgflK4agGf?p=preview


Though to be honest there’s so many unresolved question marks I’m not sure 
it’s that helpful in keeping a reign on the scope of the question... but I’d 
really appreciate absolutely any guidance be it just an example that 
achieves something similar or a helpful tutorial or the concepts I might be 
overlooking to help me get closer. I have looked at a lot of tutorials 
around the web & on pluralsight but not found anything that covers anything 
similar enough to help me get my head around it.


(Also a dupe of this question with code snippets here 
<http://stackoverflow.com/questions/38896226/angular2-add-and-submit-a-new-formgroup-name-and-values-with-model-driven-form>
)


Thanks!


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to