@ice174 wrote:
I am new in ionic 4. I am doing shopping cart function. I want to delete the selected item. But it delete like pop function not delete the certain item. I have follow this tutorial : https://devdactic.com/dynamic-ionic-4-slides/
In service ts I am using this function
then
Cart.page.tsonDeleteItem(i) { const index = this.selectedItems.indexOf(i); if (index > -1) { this.cartServ.deleteFromCart(index); this.selectedItems.splice(index, 1); console.log(this.selectedItems); } this.total = this.selectedItems.reduce((a, b) => a + (b.count * b.price), 0); }
Cart.service
addToCart(product) { this.cartService.addProduct(product); } deleteFromCart(i) { console.log(i); if (i === 0) { this.cart.shift(); } else { this.cart.splice(i, 1); } }
Anyone can help me?
Posts: 1
Participants: 1