【问题标题】:basic nested routes in emberjsemberjs 中的基本嵌套路由
【发布时间】:2013-08-17 11:32:26
【问题描述】:

我有这个路由器

App.Router.map(function() {
    this.resource('about', function() {
        this.route('new');
    });
});

和

<script type="text/x-handlebars" data-template-name="about/new">
    <h1>About/New Page</h1>
</script>

但是,当我转到 about/new 路线时,我只看到 about 模板。那么,如何渲染嵌套路由的模板呢?

这是一个 jsfiddle:http://jsfiddle.net/C4gSE/

【问题讨论】:

  • 我已经回答了你的问题,但这似乎是一个错误。很奇怪。

标签: ember.js routing ember-router ember-model


【解决方案1】:

about 模板中缺少 outlet 帮助器。 应该是

<script type="text/x-handlebars" data-template-name="about">
    <h2>About</h2>
    {{outlet}}
</script>

【讨论】:

    【解决方案2】:

    您需要将data-template-name 从about 更改为about/index。 而linkTo 从about 到about.index

    Like this sample

    【讨论】:

    • 好的!另外,还有一件事,当我点击about/new 时,about 和about.new 部分都是“活动的”。我的意思是,看看这个小提琴:jsfiddle.net/fsP44/2 这是否意味着AboutNewController 将拥有AboutIndexController 的所有属性?
    • 使用linkTo 'about.index'。像这个例子jsfiddle.net/marciojunior/fsP44/3
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-13
    相关资源
    最近更新 更多