問題描述
具有多維數組的Angular 2動態形式 (Angular 2 dynamic form with multidimensional array)
我正在嘗試使用多個可重複使用的部分構建一個表單。我正在使用 json 對象來保存表單數據。表單正在構建而沒有錯誤。我正在使用角度反應形式。所以我不能添加 formArrayName 名稱。當我添加它時顯示錯誤。必須是formAraryName嗎?因為沒有它,當我選擇一個下拉列表並在第一個下拉列表中加載另一個選擇下拉數據庫時,它第一次正確加載。但是,當我將另一個組推送到數組並在第一個下拉列表中選擇一個選項時,它會更改所有第二個下拉列表值。如何在不更改以前的數據的情況下加載數據。
表單看起來像
參考解法
方法 1:
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.
(by Sameera Herath、Indrajeet Gajbhiye)