Last active
July 6, 2018 17:52
-
-
Save ASH-terrance/5da6d17bac3c8fbdd1537d2193e3dd0b to your computer and use it in GitHub Desktop.
computed-properties
This file contains 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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains 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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'ul' | |
}); |
This file contains 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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
isCheap: Ember.computed('model.@each.price', function() { | |
let model = this.get('model'); | |
return model.filter((item) => { | |
return item.price < 5 | |
}); | |
}), | |
mostExpensive: Ember.computed('model.@each.price', function() { | |
let model = this.get('model'); | |
let expensive = model.reduce((a, b) => { | |
return a.price > b.price ? a : b; | |
}); | |
return expensive; | |
}), | |
isFeatured: Ember.computed.filterBy('model', 'isFeatured', true), | |
itemSorting: ['item:asc'], | |
sortedItemAsc: Ember.computed.sort('model', 'itemSorting'), | |
isCheapKey: ['isCheap:desc'], | |
isCheap: Ember.computed.sort('model', 'isCheapKey') | |
}); |
This file contains 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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return [ | |
{ id: 1, item: 'Pants', price: 9.99, isFeatured: false, isCheap: false }, | |
{ id: 2, item: 'Shirt', price: 6.99, isFeatured: false, isCheap: false }, | |
{ id: 3, item: 'Belt', price: 4.99, isFeatured: false, isCheap: true }, | |
{ id: 4, item: 'Socks', price: 5.99, isFeatured: false, isCheap: true }, | |
{ id: 5, item: 'Underwear', price: 10.99, isFeatured: true, isCheap: false } | |
] | |
} | |
}); |
This file contains 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
{ | |
"version": "0.13.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment