question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigating with outlets is confusing: outlets map does not apply to consumed segments

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Reactions:24
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

11reactions
bennadelcommented, Oct 10, 2017

For what it’s worth, I was able to get this working by using the parent component’s ActivatedRoute instance (this.activatedRoute.parent) in the router.navigate() method. I wrote up my approach here.

8reactions
colltoactioncommented, Dec 16, 2016

Update: Router.navigate doesn’t work either. E.g. the following doesn’t work:

this.router.navigate(["/profile", { outlets: { sidebar: null } }]);

Workaround: add a click handler and call navigate a second time, but only after the first one completes.

this.router.navigate(["/profile"]).then(() =>
            this.router.navigate([".", { outlets: { sidebar: null } }]));
Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found