您必須使用查詢參數,這些查詢參數在此時只能在金絲雀版本中激活。
主題的參考可以在這裏找到:
https://github.com/emberjs/ember.js/pull/3182
的一般方式做到這一點是這樣的:
App.Router.map(function() {
this.resource('posts', {queryParams: ['sort', 'direction']}, function() {
this.resource('post', {path: "/:id", queryParams: ['showDetails']});
});
});
App.IndexRoute = Ember.Route.extend({
beforeModel: function(transition, queryParams) {},
model: function(params, transition, queryParams) {},
afterModel: function(resolvedModel, transition, queryParams) {},
setupController: function(controller, context, queryParams) {},
renderTemplate: function(controller, context, queryParams) {}
});
/// transitionTo now will accept a final argument, which must be an object with the key queryParams.
this.transitionTo('post', object, {queryParams: {showDetails: true}});
this.transitionTo('posts', {queryParams: {sort: 'title'}});
this.transitionTo({queryParams: {direction: 'asc'}});
/// You can also use add query params to URL transitions as you would expect:
this.transitionTo("/posts/1?sort=date&showDetails=true");
這是關於queryParams,但我說的params參數就像你傳遞給你的IndexRoute中的模型方法一樣。也許這是我的一個誤解,但是這是如何針對我的問題的?我的問題是基於動態細分市場 – Arch
這可能有幫助。 https://github.com/emberjs/ember.js/issues/1997 – borisrorsvort
酷,我會看看 – Arch