Navigating with outlets is confusing: outlets map does not apply to consumed segments
See original GitHub issueI’m submitting a …
[X] bug report
Current behavior
I have some routes like:
const routes = [
{ path: "", component: HomeComponent, pathMatch: "full" },
{ path: "profile", component: ProfileComponent },
{ path: "menu", component: MenuComponent, outlet: "sidebar" },
];
When the route http://localhost/(sidebar:menu)
is open, then I’m able to remove the named outlet and go to http://localhost/
by clicking an anchor like the following:
<a [routerLink]="['', {outlets: {sidebar: null}}]">
Close
</a>
What doesn’t work is navigating away from the sidebar and also going to another route like http://localhost/profile
.
<a [routerLink]="['/profile', {outlets: {sidebar: null}}]">
Close
</a>
The link that is rendered is http://localhost:3971/profile(sidebar:menu)
Expected behavior
The link that should be rendered is http://localhost:3971/profile
.
Repro
https://github.com/tinchou/router-repro
Please tell us about your environment:
Windows 10, Visual Studio 2017
-
Angular version: 2.3.1 (didn’t work with 2.1.0 either)
-
Browser: all
-
Language: TypeScript 2.0.10
Issue Analytics
- State:
- Created 7 years ago
- Reactions:24
- Comments:21 (7 by maintainers)
Top Results From Across the Web
Angular 2 optional route parameter - Stack Overflow
Angular 4 will correctly follow products for routes with no parameter, and if a parameter it will follow products/:id .
Read more >Navigation map APIs and SDKs - Mapbox
Use Mapbox navigation maps for live traffic, lane guidance, and turn-by-turn navigation.
Read more >Understanding Customer Experience
Whether it is a business or a consumer being studied, data about its experiences are collected at “touch points”: instances of direct contact...
Read more >An Easy Guide to Deutsche Bahn - Navigating German Train ...
Navigating German train travel is easier than you'd think. Here's a guide to Deutsche Bahn to help you on your next adventure!
Read more >Route - Angular
Empty-path route configurations can be used to instantiate components that do not 'consume' any URL segments. In the following configuration, when navigating to ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For what it’s worth, I was able to get this working by using the parent component’s
ActivatedRoute
instance (this.activatedRoute.parent
) in therouter.navigate()
method. I wrote up my approach here.Update:
Router.navigate
doesn’t work either. E.g. the following doesn’t work:Workaround: add a click handler and call navigate a second time, but only after the first one completes.