【发布时间】:2018-03-08 01:52:05
【问题描述】:
如何在我的 EditForm 中填充这个 JSON。我有 EditForm,我想在 Products 中显示我的数据,我的 ws 给我这个 JSON。我可以在 html 中显示的产品之外的数据。有什么问题?
这是我的 Json
{
"StatusCode": 0,
"StatusMessage": "OK",
"StatusDescription": [
{
"Products": [
{
"p_product_id": "11E8218A54B30C89AE8800FF76874A59",
"p_product_type_id": "11E7FC041F467AD4B09D00FF76874A59",
"p_line_num": 233,
"p_description": "test",
"p_quantity": 4,
"p_unit_price": 50,
"p_subtotal": 120,
"p_contract_filename": "567897"
}
],
"sale_item_id": "11E8219D916A69F6AE8800FF76874A59",
"sale_id": "11E8218B9BA4F278AE8800FF76874A59",
"client_id": "11E8218A57B28B0AAE8800FF76874A59",
"salesman_id": "31000000000000000000000000000000",
"sale_date": "2018-03-06T22:09:43.000Z",
"notes": "testing",
"subtotal": 80,
"total": 50,
"invoice_number": "28282",
"invoice_date": "2018-03-06T21:57:41.000Z",
"amount_paid": 32,
"lastmoduserid": "31000000000000000000000000000000",
"lasttodtttm": "2018-03-06T22:09:43.000Z"
}
]
}
我的ts代码:
this.sale.products.forEach(x => {
(this.editSaleForm.get('products') as FormArray).push(new FormControl(x.products))
})
html代码:
<tr class="group" style="cursor: pointer" *ngFor="let sale of editSaleForm.get('products').value; let i = index">
<td >{{p_product_type_id}}</td>
<td>{{p_product_id}}</td>
<td>{{p_unit_price}}</td>
<td>{{p_quantity}} </td>
</tr>
【问题讨论】:
-
let sale of editSaleForm.get('products').value您是否要为每次销售获取sale.value?
标签: html angular forms typescript reactive