Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

If else on "like" button"

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>