2014-09-20 52 views
0

我想创建几个页面,将使用相同的菜单,以便我可以轻松地保存菜单的状态,并避免代码重复。我的问题是菜单模板不会在页面的菜单出口中呈现。模板不渲染到命名插座

下面是代码:

App.Router.map(function() { 
    // put your routes here 
    this.resource('profil', function() { 
    this.route('news'); 
    this.route('menu'); 
    }); 
}); 

App.MenuRoute = Ember.Route.extend({ 
renderTemplate: function() { 
    this.render({ 
     into: 'profil/news', 
     outlet: 'menu', 
    }); 
    } 
}); 

而且index.html中我有:

<script type="text/x-handlebars" id="profil/news"> 
    ... 
    {{outlet}} 
    {{outlet menu}} 
</script> 

<script type="text/x-handlebars" id="menu"> 
    ... 
</script> 

'PROFIL /新闻' 被渲染,但模板 '菜单' 是不是在渲染模板全部:当我访问profil /新闻时,它应该在'profil/news'内部呈现。任何想法 ?

谢谢

回答

0

问题是,我需要使用:

<script type="text/x-handlebars" id="profil/news"> 
    ... 
    {{outlet}} 
    {{render 'profil/menu'}} 
</script> 

而要改变车把的名称相匹配的路由:

<script type="text/x-handlebars" id="profil/menu"> 

此外,声明从App.Menuroute开始是不必要的,并被删除。

现在一切都按预期工作。