代わりに試す
{{#linkTo 'team.bob'}}bob{{/linkTo}}
その間、この方法でルーターマップを簡素化できます-ルート名と異なる場合にのみパスを指定する必要があります.
App.Router.map(function() {
this.route("site", { path: "/" });
this.route("about");
this.resource("team", function(){
this.route('bob');
});
});
アップデート
ここで実際の例を参照してください
要約すると、テンプレートをレンダリングする場所を明示的に指定する TeamBobRoute の renderTemplate 関数の実装を提供する必要がありますbob
。render オプションinto
を使用すると、デフォルトの動作をオーバーライドして、親アウトレットにレンダリングし、レンダリング先の親テンプレートを選択できます
App.TeamBobRoute = Ember.Route.extend({
renderTemplate:function(){
this.render('bob',{
into:'application',
});
}
});
<script type="text/x-handlebars" data-template-name="site-template">
This is the site template
{{#linkTo 'about'}}about{{/linkTo}}
{{#linkTo 'team'}}team{{/linkTo}}
</script>
<script type="text/x-handlebars" data-template-name="about">
This is the about page
</script>
<script type="text/x-handlebars" data-template-name="team">
This is the team page
{{#linkTo 'team.bob'}}bob{{/linkTo}}
</script>
<script type="text/x-handlebars" data-template-name="bob">
This is the bob page
</script>
<script type="text/x-handlebars">
This is the application template
{{outlet}}
</script>
参考までに、render メソッドは次のオプションをサポートしていますinto, outlet and controller
。
PostRoute
ルータで定義されているの名前は ですpost
。
デフォルトでは、render は次のことを行います。
post
テンプレートをレンダリングする
- イベント処理用の
post
ビュー ( ) (存在する場合)PostView
- および
post
コントローラー ( PostController
) (存在する場合)
- テンプレートの
main
アウトレットにapplication
この動作をオーバーライドできます。
App.PostRoute = App.Route.extend({
renderTemplate: function() {
this.render('myPost', { // the template to render
into: 'index', // the template to render into
outlet: 'detail', // the name of the outlet in that template
controller: 'blogPost' // the controller to use for the template
});
}
});
アプリケーション テンプレート内に名前付きテンプレートがある場合は、この方法でターゲットに設定します。
App.TeamBobRoute = Ember.Route.extend({
renderTemplate:function(){
this.render('bob',{
into:'application',
outlet:'team-member',
});
}
});
<script type="text/x-handlebars">
This is the application template
{{outlet 'team-member'}}
{{outlet}}
</script>