Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
glips: [
Ember.Object.create({
status: 'alive'
}),
Ember.Object.create({
status: 'dead'
}),
],
thangs: Ember.computed.map('glips', function(g) {
return g.get('status');
}),
things: Ember.computed.map('glips.@each.status', function(g) {
return g.get('status');
}),
actions: {
doTheThing() {
const glip = this.get('glips.firstObject');
glip.set('status', 'changed!!!');
console.log(this.get('glips'));
}
}
});
<code> things: Ember.computed.map('glips.@each.status'</code>
{{#each things as |t|}}
<p>{{t}}</p>
{{/each}}
<code> Ember.computed.map('glips'</code>
{{#each thangs as |t|}}
<p>{{t}}</p>
{{/each}}
<button {{action "doTheThing"}}>Update the thing</button>
{
"version": "0.13.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.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