Created
February 18, 2016 18:30
-
-
Save davelowensohn/a566a3fa28f167423fe3 to your computer and use it in GitHub Desktop.
Ember 2.x nested @each workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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