How to increment & decrement item quantity of particular item

Hello,

I have an Array of item in shopping cart i want to update the quantity of particular item in cart when user clicks the inc or dec button

my ts file

// Fetching the data in shopping cart
this.storage.get('products').then(data => {
      for (var i = 0; i < data.length; i++) {
        this.bag.push(data[i]);
      }
      for (var i = 0; i < this.bag.length; i++) {
        this.item_qty = this.bag[i].qty;
      }
    }
    );

decQuant() {
    if (this.item_qty - 1 < 1) {
      this.item_qty = 1;
    }
    else {
      this.item_qty -= 1;
    }
  }

  incQuant() {
     this.item_qty += 1;
    console.log(this.item_qty);
  }

With the above code the items are being updated but instead of updating the quantity of particular item its increasing every items quantity.

how can i make the it update only the selected items’s quantity

56%20PM

Please help…

Found the solution :wink:

decQuant(i) {
    if (this.bag[i].qty - 1 < 1) {
      this.bag[i].qty = 1;
    }
    else {
      this.bag[i].qty -= 1;
    }
  }

  incQuant(i) {
    this.bag[i].qty += 1;
    console.log(this.bag[i].qty);
  }