In your component code, first initialize a quantity
property for each product
in the productlist
// After getting the list of products...
this.productlist.foreach(product => { product.quantity = 0; });
// ...
Also update the decrement
and increment
functions to receive the product
that should be modified:
increment(product: any) {
product.quantity++;
}
decrement(product: any) {
if(product.quantity > 0) {
product.quantity--;
}
}
Now in the view, you can use the new quantity
property to show the quantity multiplied by the price. Also notice that now we sent the product
to the increment
and decrement
functions:
<ion-icon ... (click)="decrement(product)"></ion-icon>
{{ product.quantity * product.PPrice }}
<ion-icon ... (click)="increment(product)"></ion-icon>