问题
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