In my cart model, I have items stored with item_id, item_name, and item_price properties like this:
[
{
"item_id": 1,
"item_name":"Item 1",
"item_price": 500
},
{
"item_id": 2,
"item_name": "Item 2",
"item_price": 230
},
{
"item_id": 3,
"item_name": "Item 3",
"item_price": 150
}
]
To calculate the total cost of all items in the cart, I need to sum up the item_price property. This total will be displayed and then passed to ember data or an ajax call for completing a purchase.
I am attempting to use Ember's computed functionality to achieve this, but I may not completely understand how to aggregate data using computeds. Here is what I have tried:
totalDue: Ember.computed.sum('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6cbc9c2c3ca88e6c3c7c5ce88cfd2c3cb">[email protected]</a>_price')
However, the controller is returning a total of 0. I am currently utilizing ember version 2.2.0.