我需要创建2条路线
/users/philosophy
/topic/philosophy
在/users/上有一个类别列表,在topic上有一个类别列表。在/users/philosophy上,有按类别列出的用户列表和主题相同的用户列表。类别是一样的。所以我创建了路由器:
this.resource('categories', { path: '/:section' }, function(){
this.resource('category', {path: '/:url'});
});而且它是有效的。但是现在我想为用户列表添加过滤器/users/philosophy/top。我试过这样做:
this.resource('categories', { path: '/:section' }, function(){
this.resource('category', {path: '/:url/:filter'});
});但是如果将段top从url中删除,则会抛出错误,因此filter param成为必要的。我怎样才能使filter不必要?或者请用另一种方法来构建路由器。
发布于 2015-05-08 11:24:42
似乎你说的是余烬查询仿射。
App.CategoriesCategory = Ember.Controller.extend({
queryParams: ['filter'],
filter: '' /* default value */
});并使用filter参数将用户传输到此路由,请使用以下助手
{{#link-to 'categories.category' url (query-params filter="top")}}Show top{{/link-to}}如果不想使用该参数,则跳过查询参数。
https://stackoverflow.com/questions/30121845
复制相似问题