Currently, I am having some issues while working with classes:
The error message displayed is:
TypeError: _this.Order.orderRow is undefined
The error occurs when attempting to add a new row to the orderRow array.
Here is the code snippet:
Order Class
export class Order {
public orderRow?: OrderRow[];
public rowNumber?: number;
constructor(values: Object = {}) {
Object.assign(this, values);
}
}
export class OrderRow {
public rowNumber:number;
public idSaleOrderRow?: number;
public idCollection?: number;
public idProduct?: number;
public txtCollection?: string;
public txtName?: string;
public productName?: string;
public vQty?: number;
public vQtyFill?: number;
public vSellPrice?: number;
public vCustomerPrice?: number;
public vCustomerPriceFinal?: number;
constructor(values: Object = {}) {
Object.assign(this, values);
}
}
Code snippet causing error
Order: Order = <Order>{};
...............
...............
let r:OrderRow = {
rowNumber: newRowNumber,
idSaleOrderRow: null,
idCollection: res.result.idCollection,
idProduct: res.result.idProduct,
txtCollection: res.result.txtCollection,
txtName: res.result.txtName,
productName: res.result.productName,
vQty: 1,
vQtyFill: null,
vSellPrice: res.result.vSellPrice,
vCustomerPrice: res.result.vSellPrice,
vCustomerPriceFinal: res.result.vSellPrice
};
this.Order.orderRow.push(r);
Any suggestions on how to resolve this issue would be greatly appreciated.
Thank you for your assistance.