Skip to content

Instantly share code, notes, and snippets.

@Dhaulagiri
Created March 6, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dhaulagiri/64b94e9b4250e4de22046f59d72e1652 to your computer and use it in GitHub Desktop.
Save Dhaulagiri/64b94e9b4250e4de22046f59d72e1652 to your computer and use it in GitHub Desktop.
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