I am learning angular, following one tutorial and my code shows error while if i copy the code of the instructor, it does work even though it seems to me that the only difference in our codes is this one function wrote differently.
I spent like 2 hours looking at this code, compared his and mine versions but still cant figure out the problem.
Mine code:
calculateOrders() {
this.customersOrderTotal = 0;
this.filteredCustomers.forEach(function(cust: ICustomer){
this.customersOrderTotal += cust.orderTotal;
});
}
His code:
calculateOrders() {
this.customersOrderTotal = 0;
this.filteredCustomers.forEach((cust: ICustomer) => {
this.customersOrderTotal += cust.orderTotal;
});
}