Sameera Herath
Sameera Herath

Reputation: 201

Angular 2 dynamic form with multidimensional array

I'm tyinng to build a form using multiple reusable sections. I'm using a json object to keep the form data. Form is building without an error. I am using angular reactive forms. So I can't add formArrayName name. it when I add it showing error. Is it must formAraryName? Because without it when I select a dropdown and load another select dropdown data base on first one, the first time it loads correctly. But when I push another group to the array and select an option in first dropdown it change all second dropdown values. How can I load data without changing previeous ones.

Form looks like

enter image description here

code

enter image description here

ui examples

1st time

enter image description here

2nd time

enter image description here

Upvotes: 0

Views: 246

Answers (1)

Indrajeet Gajbhiye
Indrajeet Gajbhiye

Reputation: 51

I think this repository here can help you.

https://github.com/indrajeetgajbhiye/reactiveFormsDemo

Dynamic formArray implementation upto 3 layers. You can extend it as per your wish.

Upvotes: 1

Related Questions