EmberJS - How to partially nest parent and sub routes?

早过忘川 提交于 2020-01-16 17:59:07

问题


I have a lot of nested urls.

e.g. Project list -> Project detail

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

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}}

Note that some elements of Project list should be still display in Project detail.

Is there a better way to do this?


回答1:


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.



来源:https://stackoverflow.com/questions/54335421/emberjs-how-to-partially-nest-parent-and-sub-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!