我正在尝试复制一个模型对象数组,这些对象是在对本地Array变量进行RESt调用时返回的对象的一部分。我创建了一个GrnDetailModel然后创建了一个空的Array数组来将数组复制到REST服务返回的数组中... 当我尝试将数组复制到Array变量时,我收到以下错误:"键入' string'不能分配给' GrnDetailModel []'"。当我在console.log中返回被返回的对象时,我可以看到它是一个数组,而不是一个字符串...任何想法可能导致这个/如何修复它?
当我执行以下操作时:
for (var i = 0; i < this.grn.GRNDetails.length; i++) {
this.grnDetailList.push(this.grn.GRNDetails[i]);
}
它成功复制了数组但是我无法通过局部变量访问任何模型类对象的变量,例如:
console.log(this.grnDetailList[i].barcode);
返回属性&#39;条形码&#39;在GrnDetailModel类上不存在...
我的模特:
export class GrnDetailModel {
constructor(
AccUnit: string,
Account: string,
AutoCalc: boolean,
BarCode : string,
BranchIDKey: string,
Branch_Name: string,
Branch_UserCode: string,
Charges: string,
Comment: string,
Confirmed: boolean,
CostChanged: boolean,
CostTax: string,
DiscExc: string,
DiscInc: string,
DiscInt: string,
DiscNarr: string,
DiscOrd: string,
DiscountTemplate_Name: string,
DiscountTemplate_UserCode: string,
GPPerc: string,
GRNDocument: null,
GRNDocument_Comment: string,
GRNDocument_UserCode: string,
GrossCost: string,
HeaderID: string,
IDKey: string,
NettCost: string,
OrgCost: string,
OrgPurchCount: string,
OrgSelling: string,
PORDDetailIDKey: string,
PriceListIDKey: string,
PriceList_Name: string,
PriceList_UserCode: string,
ProductDetail_Name: string,
ProductDetail_UserCode: string,
ProductIDKey: string,
Profit: string,
PurchCount: string,
PurchUOMIDKey: string,
PurchUOM_Name: string,
PurchUOM_UserCode: string,
QtyDel: string,
QtyOrd: string,
ReturnTypeIDKey: string,
ReturnType_Name: string,
ReturnType_UserCode: string,
SellChanged: boolean,
SellCount: string,
SellingPrice: string,
SellingTax: string,
SellingUOMIDKey: string,
SellingUOM_Name: string,
SellingUOM_UserCode: string,
Seq: string,
ShortageTypeIDKey: string,
ShortageType_Name: string,
ShortageType_UserCode: string,
SubGroupIDKey: string,
SubGroup_Name: string,
SubGroup_UserCode: string,
SuppRef: string,
SupplierCost: string,
SupplierZone_Name: string,
SupplierZone_UserCode: string,
Target: string,
TaxRateIDKey: string,
TaxRate_Description: string,
TaxRate_UserCode: string,
TemplateIDKey: string,
TimeStamp: string,
TotAddTax: string,
TotAddValue: string,
TotalCost: string,
TotalGP: string,
TotalSelling: string,
TotalStkQty: string,
TotalWeight: string,
Type: string,
ZoneIDKey: string){}
}