EmberJS-如何部分嵌套父级和子级路由? [英] EmberJS - How to partially nest parent and sub routes?

查看:99
本文介绍了EmberJS-如何部分嵌套父级和子级路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多嵌套的网址。

例如项目列表-> 项目详细信息

The 项目列表模板的路由仅在未调用路由项目详细信息的情况下才显示列表。

The Project list template's route should only display the list if the route Project details is not called.

我通过创建一个计算属性来做到这一点,该属性检查服务器路由 currentRouteName

I did it by creating a computed property that check the currentRouteName of the server routing.

然后将其添加到模板中:

Then I add this to my template:

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

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

请注意的某些元素项目列表仍应显示在项目详细信息中。

有没有更好的方法要这样做吗?

Is there a better way to do this?

推荐答案

您使用了错误的路线。使用 projects / index 作为列表,使用 projects / detail /:project_id 作为详细信息。仅在两种情况下都应显示时,才将它们放入项目

you use the wrong routes. use projects/index for the list and projects/detail/:project_id for the detail. Only put something in projects when it should be shown in both cases.

这篇关于EmberJS-如何部分嵌套父级和子级路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆