<p><b>Qty :</b>
<ion-icon name="remove-circle" (click)="decrement()"></ion-icon>
{{cart.qty}}
<ion-icon name="add-circle" (click)="increment()"></ion-icon>
</p>
Here is cart.ts code
ionViewDidLoad() {
var param = "user_id=" + this.user_id;
this.UtilsService.makeAPICall(this.UtilsService.postMethod,
this.UtilsService.CartItemAPI, param, (response) => {
if(response.data)
{
this.Data = response["data"];
this.Qty = response["qty"];
localStorage.setItem("qty", this.Qty);
}
});
}
How to + and - quantities in that code?
There's a lot of ways to do this, but since you're saving the quantity in your localStorage having a method to do this is the best way. So in your
.ts
file you'll haveAlso you can't access it with
{{cart.qty}}
, you need{{Qty}}
instead.If you don't need to save it all the time in the localStorage you can do it inline in your HTML
Hope this helps.