Last active
March 16, 2017 16:05
-
-
Save dfreeman/03ccf81ad44014129df7029608804623 to your computer and use it in GitHub Desktop.
checkboxes
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
products: Array.from(Array(100), (_, i) => ({ id: i, name: `Product #${i}` })), | |
displayItems: Ember.computed.map('products', product => ({ product, checked: false })), | |
selectedItems: Ember.computed.filterBy('displayItems', 'checked'), | |
selectedItemNames: Ember.computed('selectedItems.[]', function() { | |
return this.get('selectedItems').mapBy('product.name').join(', '); | |
}), | |
actions: { | |
toggleAll(checked) { | |
for (const item of this.get('displayItems')) { | |
Ember.set(item, 'checked', checked); | |
} | |
} | |
} | |
}); |
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
{ | |
"version": "0.11.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.11.0", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.11.0", | |
"ember-testing": "2.11.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment