I am trying to create some computed properties with an Ember ObjectController and am experiencing some difficulties. My object (Baz) contains an array of objects (Foo). Each Foo has some key/value pairs, let's call them alpha and beta.
Using code like this:
App.BazController = Ember.ObjectController.extend({
total: function() {
return this.get('foos').getEach('alpha').reduce(function(accum, item) {
return accum + item;
}, 0);
}.property('[email protected]')
});
I can calculate the sum of every Foo object's 'alpha' property but I would like to calculate values between specific Foos, ideally selected by their built-in ID. I have tried a fairly wide variety of expressions to try and select an individual Foo object out of the array but I can't seem to figure it out.
Can this be accomplished within an ObjectController or is this the wrong place to try and compute such values?
Any help from code to a conceptual walkthrough would be greatly appreciated.
Cheers, Allen