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.ts
onDeleteItem(i) {
const index = this.selectedItems.indexOf(i);
if (index > -1) {
this.cartServ.deleteFromCart(i);
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) {
const index = this.cart.indexOf(i);
if (index > -1) {
this.cart.splice(index, 1);
}
}
Anyone can help me?
Cart.page.tsretrieves with agetter(). You shouldn't be maintaining 2 identical lists.