Having trouble populating my array due to instantiation issues.
Defined Models:
user: User = {
firstName: "",
lastName: "",
address: ""
}
order: Order = {
OrderId: "",
User: this.user,
TotalPrice: 0,
OrderItems: []
}
Attempting to populate the Order:
this.Identity.getMail().then(user => this.order.OrderId == user.email);
this.order.User = this.user;
this.order.TotalPrice = this.cartTotal;
this.cartItems.forEach((item, index) => {
this.order.OrderItems[index].ProductName = item.productName,
this.order.OrderItems[index].ProductPrice = item.price,
this.order.OrderItems[index].ProductQuantity = item.quantity
})
Encountering an error:
CartFullComponent.html:21 ERROR TypeError: Cannot set property 'ProductName' of undefined
How can I properly instantiate order.OrderItems to accept values?