Forked from ASH-terrance/components.cheap-socks.js
Last active
July 25, 2018 19:25
-
-
Save terrancebryant/886c16cd5ff89b938dfb358409e3891b 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', | |
cheapSocks: 4, | |
hasChaapSocks: Ember.computed.lt('cheapSocks', 5), | |
priceMap: Ember.computed.mapBy('model', 'price'), | |
biggestNumber: Ember.computed.max('priceMap'), | |
mostExpensive: Ember.computed.filter('model', function(model, index, array) { | |
const exp = this.get('biggestNumber'); | |
return model.price >= exp | |
}), | |
isCheap: Ember.computed('model.@each.price', function() { | |
let model = this.get('model'); | |
return model.filter((item) => { | |
return item.price < 5 | |
}); | |
}), | |
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