我有以下路线
App.Router.map(function(match) {
this.route("days", { path: "/" });
this.resource("day", { path: "/:day_id" }, function() {
this.resource("slots", { path: "/slots" }, function() {
this.resource("slot", { path: "/:slot_id" }, function() {
this.route("edit", { path: "/edit" });
});
});
});
});
我有以下模板
script/app/templates/application.handlebars
script/app/templates/days.handlebars
script/app/templates/day.handlebars
script/app/templates/day/index.handlebars
script/app/templates/slots.handlebars
script/app/templates/slots/index.handlebars
script/app/templates/slot.handlebars
script/app/templates/slot/index.handlebars
script/app/templates/slot/edit.handlebars
- 以上是否正确
- 如果我打算执行以下操作(不包括几天),每个车把模板中应该包含什么 html
假设我要执行以下操作(不包括天数),我需要定义哪些路线
- 选择一天时,我想显示关联模型的列表(在这种情况下为插槽)
- when a slot is selected I want the html from it's index page (showing an individual slot based on the slot id param being passed to the route)
更新
到目前为止,看起来标有“资源”的路由需要有一个 {{outlet}} 可用于内部资源或路由以放入一些标记。
例如 day.handlebars 模板有一个 {{outlet}} 并且在我的 day/index.handlebars 模板中我放入一个 for 循环来显示每一天。接下来在 slot.handlebars 模板中,我包含一个 {{outlet}} 并在 slot/index.handlebars 模板中添加另一个 for 循环以显示每个可用的插槽。