I have an animated like button that on click adds the product to the wishlist/favorites
addToCart(product: Product) {
console.log(`add ${product.title} to cart`)
this.cartService.addProduct(product);
}
This toggles the animation from ‘heart-outline’ to ‘ios-heart’. If you click it again it reverts from ‘ios-heart’ to ‘ios-outline’. All good so far.
What I want to do is remove the product from the wishlist/favorites on second click (if the product is in the cart) using
removeFromCart(product: Product) {
console.log(`remove ${product.title} from cart`)
this.cartService.removeProduct(product);
}
I have a feeling this is fairly simple to do but cannot figure it out. Is there a way using if else in the ts file ?
1 post - 1 participant