You can put together a reduceComputed property for sum
. Here are a few links for inspiration: one, two, and three. Basically, you can do something like this:
Ember.computed.sum = function (dependentKey) {
return Ember.reduceComputed.call(null, dependentKey, {
initialValue: 0,
addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
return accumulatedValue + item;
},
removedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
return accumulatedValue - item;
}
});
};
Then, in your controller do something like this:
App.CartController = Em.ArrayController.extend({
prices: Ember.computed.mapBy('content', 'fullPrice'),
totalPrice: Ember.computed.sum('prices')
});