Skip to content

Instantly share code, notes, and snippets.

@davelowensohn
Created February 18, 2016 18:30
Show Gist options
  • Save davelowensohn/a566a3fa28f167423fe3 to your computer and use it in GitHub Desktop.
Save davelowensohn/a566a3fa28f167423fe3 to your computer and use it in GitHub Desktop.
Ember 2.x nested @each workaround
// Nested eaches don't work, as per Ember rules:
// computedOrderSubTotal: computed('[email protected][email protected]') [....]
// Workaround:
nestedProperties: computed.mapBy('allOrderItems', 'properties'),
computedOrderSubTotal: computed('[email protected]', '[email protected]', {
get() {
return this.get('nestedProperties').map( item => item.pricePerUnit * item.qty).reduce( (a,b) => a + b, 0);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment