我有router
:
// app/router.js
Router.map(function() {
this.route('battles', function(){
this.route('battle', { path: ':id' }, function(){
this.route('combats', function() {
this.route('new');
});
});
});
});
这些templates
:
// app/templates/battles.hbs
{{#each model as |battle|}}
{{battle.name}}
{{/each}}
{{outlet}}
// app/templates/battles/battle/combats.hbs
{{#each model as |combat|}}
{{combat.date}}
{{/each}}
// app/templates/battles/battle/combats/new.hbs
{{input type="text" value=date}}
<button {{action "createCombat"}}>Create Combat</button>
所以这是为每个route
route: /battles
-> app/templates/battles.hbs
route: /battles/B2/combats
-> app/templates/battles.hbs
-> app/templates/battles/battle/combats.hbs
route: /battles/B2/combats/new
-> app/templates/battles.hbs
-> app/templates/battles/battle/combats.hbs
因此,对于路线/battles/B2/combats/new
,不会呈现模板app/templates/battles/battle/combats/new.hbs
。这有一个快速解决方法:
// app/templates/battles/battle/combats.hbs
{{#each model as |combat|}}
{{combat.date}}
{{/each}}
{{outlet}}
然后路线呈现:
route: /battles/B2/combats/new
-> app/templates/battles.hbs
-> app/templates/battles/battle/combats.hbs
-> app/templates/battles/battle/combats/new.hbs
我不希望在渲染combat/new
表单时呈现战斗列表。我想这样:
route: /battles/B2/combats/new
-> app/templates/battles.hbs
-> app/templates/battles/battle/combats/new.hbs
我如何创建此设置?