/expenses?sort=date&filter=drinks
/we/have/many/routes?yet=only_one_query_string
/not;all=servers/support;matrix=parameters
ember-query
(Alex Speller)ember-query-params
(Elte Hupkes)App.SortedPostsController = Ember.ArrayController.extend({
queryParams: ['sortVar:sort', 'page'],
sortVar: 'date:desc'.
page: 1
});
App.PostsRoute = Ember.Route.extend({
// Flexible controller name
controllerName: 'sortedPosts',
// Hooks receive params
model: function(params, transition) {
console.log(params.sort); // date:asc
console.log(params.page); // 1
}
});
App.PostsRoute = Ember.Route.extend({
queryParams: {
sort: { refreshModel: true }
}
// Alternatively
actions: {
queryParamsDidChange: function(changed, all, removed) {
if ('sort' in changed) {
// Awesome new refresh method!
this.refresh();
}
}
}
});
controller.set('sortVar', 'date:desc');
// URL: /posts?sort=date:desc
controller.set('sortVar', 'date:asc');
// URL: /posts
// URL: /posts?page=3
console.log(typeof controller.get('page')); // "number"