Created
February 17, 2017 00:22
-
-
Save rmwxiong/3b027188a6873f2bb3e571f9dbf3c448 to your computer and use it in GitHub Desktop.
Map to array demo
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({ | |
computedValue: Ember.computed('thing.value', function() { | |
return this.get('thing.value') + '!!!'; | |
}) | |
}); |
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', | |
mapAsArray: Ember.computed('myMap', function() { | |
const myMap = this.get('myMap'); | |
const myArray = []; | |
for (const key in myMap) { | |
myArray.push({ | |
id: key, | |
value: myMap[key] | |
}); | |
} | |
return myArray | |
}), | |
thing: Ember.on('init', function() { | |
this.set('myMap', {123: 'abc', 456: 'def', 789: 'ghi'}); | |
Ember.run.later(() => { | |
this.set('myMap', {123: '555', 456: 'def', 789: '999'}); | |
}, 2000); | |
}), | |
}); |
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.11.0", | |
"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.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment