【发布时间】:2019-09-17 09:23:36
【问题描述】:
我正在通过发送一个对象来做一个 POST 请求,但我得到一个错误错误
TypeError: 无法设置未定义的属性“ItemCode”
我正在使用带有打字稿的 Angular 7
这是我的初始化 Json
objEnvio:any = <any> {
DocumentLines:<any>[]
};
这是我的代码:
Cadastrar() {
var today = new Date();
var self = this;
this.objEnvio.CardCode = something;
this.objEnvio.DocDueDate = something;
this.objEnvio.BPL_IDAssignedToInvoice = something;
$('.table-servico .mat-row').each(function(index, element){
self.objEnvio.DocumentLines[index].ItemCode =something; // this line is throwing the error
预期结果:
{
"CardCode": "C000009",
"DocDueDate": "2019-04-25",
"BPL_IDAssignedToInvoice": 1,
"DocumentLines": [
{
"ItemCode": "IT0001",
"UnitPrice": 207,
"Quantity": 4,
"TaxCode": "1101-001",
},
{
"ItemCode": "SV0003",
"UnitPrice": 110,
"Quantity": 1,
"TaxCode": "1933-001",
},
]
}
当前实际结果:
TypeError:无法设置未定义的属性“ItemCode”
【问题讨论】:
标签: angular typescript