0
我想顯示一個表格,其中重複tr將基於JSON中的數據(來自API的響應)。目前形式允許使用添加按鈕重複部分,但如何使用JSON數據做同樣的事情。如何添加使用repeatsection角度formly而不是添加按鈕的行?
http://angular-formly.com/#/example/advanced/repeating-section
我想顯示一個表格,其中重複tr將基於JSON中的數據(來自API的響應)。目前形式允許使用添加按鈕重複部分,但如何使用JSON數據做同樣的事情。如何添加使用repeatsection角度formly而不是添加按鈕的行?
http://angular-formly.com/#/example/advanced/repeating-section
在formly形式的模型值只需添加您的數據作爲下一個項目。 基於例如,如果我們將有這樣的模型
vm.model = {
investments: [
{
investmentName:'abc',
investmentDate:(new Date()).toDateString(),
stockIdentifier:'',
investmentValue:'',
relationshipName:'',
complianceApprover:'',
requestorComment:''
},
{
investmentName:'haf',
investmentDate:(new Date()).toDateString(),
stockIdentifier:'',
investmentValue:'',
relationshipName:'',
complianceApprover:'',
requestorComment:''
}
]
};
那麼當你將recive你的數據(我假設你正在使用的承諾),在隨後的承諾附加的部分recived數據vm.model.investments陣列 例如
someService.getMyData().then(function (data) {
vm.model.investments.push(data);
}