Skip to content

Instantly share code, notes, and snippets.

@backspace
Created February 16, 2016 15:06
Show Gist options
  • Save backspace/00c6df4d53c000d0a27c to your computer and use it in GitHub Desktop.
Save backspace/00c6df4d53c000d0a27c to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
queryParams: ['sort'],
sort: 'id',
xsortedMessages: Ember.computed.sort('model', 'sort'),
sortedMessages: Ember.computed('model', 'sort', function() {
return this.get('model').sortBy(this.get('sort'));
})
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return [
{id: '1', body: 'Message'},
{id: '2', body: 'Another message'},
{id: '3', body: 'Yet another message'}
];
}
});
{{link-to 'Root' 'application'}}
<br><br>
{{link-to 'Sort by body' (query-params sort='body')}}
{{link-to 'Sort by ID' (query-params sort='id')}}
<ul>
{{#each sortedMessages as |message|}}
<li>{{link-to message.body 'message' message}}</li>
{{/each}}
</ul>
{{outlet}}
<br>
<br>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('message', {path: '/messages/:message_id'});
});
export default Router;
a.active {
font-weight: bold;
}
{
"version": "0.5.3",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "1.13.13",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "1.13.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment