Updating the Count of Products in Cart
Understand how to implement product count updates within an Ember.js cart service. This lesson guides you through modifying the cart-service file to track product counts and totals, and updating the cart template to display these changes dynamically. You’ll learn to manage product quantities using Ember's reactive properties and service injection for state sharing across the app.
We'll cover the following...
We'll cover the following...
We need to specify the number of products in the cart. This functionality can be implemented by updating cart-service.
Updating the cart-service file
Let’s open the app/services/cart-service.js file and add the required functionality:
- Lines 4–20: We create a class named
Productand initialize all the values:- Line 5: We create a tracked property named