Я хочу перебрать массив объектов. но я не мог сделать цикл с "покупками".
Вот результат, который я имею на консоли:
[{
"createdAt": "Fri Aug 31 2018 15:19:03 GMT-0400
(Eastern Daylight Time)
",
"customer": {
"address": "test",
"lastname": "Carrio",
"name": "Mabel",
"phone": "786222222"
},
"purchases": {
"0": {
"product": {
"categoryS": "-L9QdqynslyGy8Ft1G9z",
"location": "en tienda",
"name": "Memoria",
"price": 12
},
"quantity": 3
}
},
"totalPrice": 36,
"uid": "fr0Yix3T2hMio3KzwAB1r6aJbZA2",
"$key": "-LLGQAB3V_PRiW2v02bx"
}]
component.ts
ngOnInit() {
this.invoiceService.getInvoices().snapshotChanges().subscribe(data => {
this.invoiceList = []
data.forEach(element => {
let x = element.payload.toJSON()
this.invoiceList.push(x);
}
}
}
}
}
list.component.html
<tr *ngFor="let invoice of invoiceList">
<td>{{invoice.customer.name}} {{invoice.customer.lastname}}</td>
<td>{{invoice.totalPrice}}</td>
<td>{{invoice.purchases.product.name}}</td>
<--- Error
</tr>
есть идеи?