EmberJS - 如何部分嵌套父路由和子路由?

EmberJS - How to partially nest parent and sub routes?

我有很多嵌套的 url。

例如Project list -> Project detail

Project list 模板的路由只应在未调用路由 Project details 时显示列表。

我通过创建计算 属性 来检查服务器 routingcurrentRouteName

然后我将其添加到我的模板中:

  <div>Element that should be display in both route.</div>

  {{#if isProjectDetail}}
    {{outlet}}
  {{else}}
    <ul> ... </ul>
  {{/if}}

请注意 Project list 的某些元素仍应显示在 Project detail 中。

有更好的方法吗?

你使用了错误的路线。使用 projects/index 作为列表,使用 projects/detail/:project_id 作为详细信息。仅在 projects 中应显示的内容在两种情况下都显示。