diff --git a/ember_admin/app/demonstrations/computed-getter/controller.js b/ember_admin/app/demonstrations/computed-getter/controller.js index 8d9ecbc..2c4d084 100644 --- a/ember_admin/app/demonstrations/computed-getter/controller.js +++ b/ember_admin/app/demonstrations/computed-getter/controller.js @@ -14,11 +14,11 @@ export default Ember.Controller.extend({ }), documentaries: [ - {name: 'Iron Man 1', release: '2008', budget: 140000000}, - {name: 'Iron Man 2', release: '2010', budget: 200000000}, - {name: 'The Avengers', release: '2012', budget: 220000000}, - {name: 'Iron Man 3', release: '2013', budget: 200000000}, - {name: 'Avengers 2', release: '2015', budget: 250000000} + {name: 'Iron Man 1', release: '2008', budget: 140000000, boxOffice: 318000000}, + {name: 'Iron Man 2', release: '2010', budget: 200000000, boxOffice: 312000000}, + {name: 'The Avengers', release: '2012', budget: 220000000, boxOffice: 623000000}, + {name: 'Iron Man 3', release: '2013', budget: 200000000, boxOffice: 408000000}, + {name: 'Avengers 2', release: '2015', budget: 250000000, boxOffice: 455000000} ], totalDocumentaryBudget: Ember.computed('documentaries.@each.budget', function(){ @@ -27,5 +27,14 @@ export default Ember.Controller.extend({ totalBudget += Number(documentary.budget); }) return totalBudget + }), + + totalDocumentaryProfit: Ember.computed('documentaries.@each.{budget,boxOffice}', function(){ + var totalProfit = 0; + this.get('documentaries').forEach(function(documentary){ + totalProfit += Number(documentary.boxOffice); + totalProfit -= Number(documentary.budget); + }) + return totalProfit }) }); diff --git a/ember_admin/app/demonstrations/computed-getter/template.hbs b/ember_admin/app/demonstrations/computed-getter/template.hbs index cb92710..55bcd64 100644 --- a/ember_admin/app/demonstrations/computed-getter/template.hbs +++ b/ember_admin/app/demonstrations/computed-getter/template.hbs @@ -6,7 +6,8 @@ Business Card: {{businessCard}}

Relevant Documentaries

{{#each documentaries as |documentary|}} - {{input value=documentary.name}}, released in {{input value=documentary.release}} for {{input value=documentary.budget}} million dollars
+ {{input value=documentary.name}}, released in {{input value=documentary.release}} for ${{input value=documentary.budget}}, bringing in ${{input value=documentary.boxOffice}}.
{{/each}} -Total budget: {{totalDocumentaryBudget}} \ No newline at end of file +Total budget: {{totalDocumentaryBudget}}
+Total profit: {{totalDocumentaryProfit}} \ No newline at end of file