Created
December 6, 2016 22:49
-
-
Save givanse/02f9f3a2cc17abd96761c9b4072ceb93 to your computer and use it in GitHub Desktop.
Working with Lists
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({ | |
list: [ | |
{name: 'r', color: 'red'}, | |
{name: 'b', color: 'blue'}, | |
{name: 'g', color: 'green'} | |
], | |
sortedList: Ember.computed('list.[]', function() { | |
let list = this.get('list'); | |
return list.sortBy('name'); | |
}), | |
filteredList: Ember.computed('sortedList', 'selectedColor', function() { | |
let list = this.get('list'); | |
let selectedColor = this.get('selectedColor'); | |
return list.filterBy('color', selectedColor); | |
}), | |
selectedColor: 'blue', | |
actions: { | |
selectColor: function(selectedColor) { | |
this.set('selectedColor', selectedColor); | |
} | |
} | |
}); |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.red { | |
color: red; | |
} | |
.green { | |
color: green; | |
} | |
.blue { | |
color: blue; | |
} |
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.10.6", | |
"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.9.0", | |
"ember-template-compiler": "2.9.0", | |
"ember-testing": "2.9.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment