具有多維數組的Angular 2動態形式 (Angular 2 dynamic form with multidimensional array)


問題描述

具有多維數組的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 HerathIndrajeet Gajbhiye)

參考文件

  1. Angular 2 dynamic form with multidimensional array (CC BY‑SA 2.5/3.0/4.0)

#angular5 #Angular






相關問題

有沒有辦法通過在firebase angular 6中搜索數組類型值來查找記錄 (Is there way to find a record by searching in array type value in firebase angular 6)

將變量傳遞給 ng-container 元素 (Passing a variable to ng-container element)

如何減少使用 *ngFor 結構指令在表中顯示列表(從數據庫中獲取的 json 對象)的時間? (how to reduce time to display a list (json object fetched from database) in a table using *ngFor structural directive?)

在 type=text Ionic 的離子輸入中只允許數字 (Allow only number in a ion-input with type=text Ionic)

如何禁用墊下拉選項從一到二? (How to disable mat drop down option from one to two?)

錯誤消息在 ngx-datatable 中無法正常工作 (Error message not working properly in ngx-datatable)

如何讓 cli 為我的應用程序添加 e2e 文件夾? (How do I have the cli add an e2e folder for my app?)

mat-table中的Angular 5 onchange輸入文本字段 (Angular 5 onchange input text field in mat-table)

從 Angular 向 Node js API 發出 HTTP 請求的正確方法是什麼? (What is the correct way to make a HTTP request from Angular to Node js API?)

如何從所有待處理的請求中取消特定請求 (How to cancel specific request from all pending request)

將 Angular 5 升級到 Angular 11 (Upgrade angular 5 to angular 11)

具有多維數組的Angular 2動態形式 (Angular 2 dynamic form with multidimensional array)







留言討論