You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular 2 relative pathing from siblings doesn't work #14480
[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
A routed component cannot use a relative path to navigate to another component; whether from the primary changing the named router outlet, or from a named router changing the primary.
The issue is written up here.
The closest routerLink syntax to navigating to a new named router outlet component is: <a [routerLink]="['', {outlets: {aux: ['details']}}]">Details</a>
However, when a routed component is already in the aux named route, this routerLink produces an extra set of parenthesis.
auth/portfolio/(home/1//aux:details)(aux:details)
If a routed component isn't already in the aux named route, then the url generated is malformed anyway.
auth/portfolio/(home/1)(aux:details)
Expected behavior
I would expect to be able to change to another route via a routerLink like the documentation says, regardless of the depth I am in the URL tree.
What is the motivation / use case for changing the behavior?
We have an application where the named router outlet is used to display lists of entities. Upon selecting an entity, the application replaces the primary router outlet with the details of the entity. Entity details control which lists are available, so navigation occurs in the primary router outlet to change which component is showing in the named router outlet.
Please tell us about your environment:
Azure App Services
Some of the issues may also have been addressed in #39456, where the aux outlets were being ignored if a primary outlet was defined in the map.
Much of this is actually working as intended. One thing to be aware of is that routerLink generates urls relative to the current activated route. So given a config like
in order to have a routerLink add the aux outlet if it is part of HomeComponent, the commands need to be <a [routerLink]="['../../', { outlets: { aux: ['details'] } }]">Details</a>. That is, given the existing route auth/portfolio/home/1, move two segments up to auth/portfolio, then apply the commands: Add 'aux:details' to the route and do not change the primary outlet. Updated example: https://stackblitz.com/edit/angular-ivy-tcmuja?file=src%2Fapp%2Fhome.component.ts (note that I only changed the routerLink on the HomeComponent)
Activity
atscott commentedon Nov 3, 2020
Closing as duplicate of #13523, #26672, #13523
Some of the issues may also have been addressed in #39456, where the aux outlets were being ignored if a primary outlet was defined in the map.
Much of this is actually working as intended. One thing to be aware of is that
routerLinkgenerates urls relative to the current activated route. So given a config likein order to have a
routerLinkadd the aux outlet if it is part ofHomeComponent, the commands need to be<a [routerLink]="['../../', { outlets: { aux: ['details'] } }]">Details</a>. That is, given the existing routeauth/portfolio/home/1, move two segments up toauth/portfolio, then apply the commands: Add 'aux:details' to the route and do not change theprimaryoutlet. Updated example: https://stackblitz.com/edit/angular-ivy-tcmuja?file=src%2Fapp%2Fhome.component.ts (note that I only changed the routerLink on theHomeComponent)angular-automatic-lock-bot commentedon Dec 4, 2020
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.