说我有这个设置:
App.Router.map(function() {
this.resource("people", {path: "people/:person_id"} function() {
this.resource("male", {path: "male"}, function() {
this.resource("clothingCollection", {collection/:collection_id}, function() {
this.route("item", {path: "item/:item_id"});
});
});
this.resource("female", {path: "female"}, function() {
this.resource("clothingCollection", {collection/:collection_id}, function() {
this.route("item", {path: "item/:item_id"});
});
});
});
});
如何导航到people / female / x / clothingCollection / y / item / z?
答案 0 :(得分:0)
这取决于你在哪里。资源名称必须是唯一的。
Why do nested resource routes reset the namespace in Ember?
App.Router.map(function() {
this.resource("people", {path: "people/:person_id"} function() {
this.resource("male", {path: "male"}, function() {
this.resource("maleClothingCollection", {collection/:collection_id}, function() {
this.route("item", {path: "item/:item_id"});
});
});
this.resource("female", {path: "female"}, function() {
this.resource("femaleClothingCollection", {collection/:collection_id}, function() {
this.route("item", {path: "item/:item_id"});
});
});
});
});
我建议将其更改为以下内容:
{{#link-to 'clothingCollection.item' model}}Go there{{/link-to}}
this.transitionTo('clothingCollection.item', model);
this.transitionToRoute('clothingCollection.item', model);
{{#link-to 'clothingCollection.item' person item}}Go there{{/link-to}}
this.transitionTo('clothingCollection.item', person, item);
this.transitionToRoute('clothingCollection.item', person, item);