I have an object of array ( form an API ), eatch object contains an array and i can't get access to the sub array:
Structure:
Billing [date, totalPrice, {productList[product1,product2]}, ..., ..., {[...,...,...]},....,....,..., {[...,...,...,]}]
My Model is:
export class Billing {
private _productsList: Array<InvoiceLine>;
private _Date: Date;
private _totalPrice: number;
}
Then I initialized an my array:
public AllBilling: Billing[] = [];
Then when I try to get my data from Blling Array it works.
for ( i = 0; i < this.AllBilling.length; i++){
console.log(this.AllBilling);
}
But when I try to get productsList form my array it doesn't work.
for ( i = 0; i < this.Belling.length; i++){
console.log(this.Belling[i]);
for ( j = 0; j < this.AllBilling[i].productsList.length; i++){
console.log(this.AllBilling[i].productsList[j]); }
}
It gives me the folowing error:
ERROR TypeError: Cannot read property 'length' of undefined
witch refer to productsList.length