Skip to content

Instantly share code, notes, and snippets.

@sly7-7
Last active October 19, 2015 12:17
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 sly7-7/f18670bdb3a1965b4e4c to your computer and use it in GitHub Desktop.
Save sly7-7/f18670bdb3a1965b4e4c to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
var things = [{id: 42, name: 'blah'},
{id: 43, name: 'oh'},
{id: 44, name: 'ah'}];
var things= [42,43, 44]
export default Ember.Controller.extend({
appName:'Ember Twiddle',
someProp: true,
sortedThings: Ember.computed('someProp', function() {
var someProp = this.get('someProp');
console.log(things);
return things.sort(function(a,b) {
return someProp === true ? a-b : b-a;
});
}),
actions: {
changeThing: function() {
this.toggleProperty('someProp');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{my-component things=sortedThings}}
<button {{action 'changeThing' on='click'}}>
hop
</button>
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
});
{{#each things as |thing|}}
{{thing}}
{{/each}}
{{things}}
{
"version": "0.4.13",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment