在我的用例中,我想从父路由导航到子路由以及从子路由导航到父路由。第一个案例有效,但第二个无效。为什么?怎么了?是renderTemplate中的错误吗?
App = Ember.Application.create();
App.Router.map(function() {
this.resource('parent',function(){
this.resource('child',function(){
});
});
});
App.ChildRoute = Ember.Route.extend({
renderTemplate: function(){
this.render('child', {
into: 'application',
controller: 'child'
});
}
});
<script type="text/x-handlebars">
<h1>Ember Sandbox</h1>
<nav>
{{#linkTo 'parent'}} Parent {{/linkTo}}
</nav>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<h2>Welcome</h2>
</script>
<script type="text/x-handlebars" data-template-name="parent">
<h2>Parent</h2>
{{#linkTo 'child'}} Child {{/linkTo}}
</script>
<script type="text/x-handlebars" data-template-name="child">
<h2>Child</h2>
{{#linkTo 'parent'}} Parent {{/linkTo}}
</script>