如何在我的EditForm中填充此JSON。我有EditForm,我想在产品中显示我的数据,我的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>