bug(router) unable to navigate to aux route in nested component
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report
[ ] 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
When defining an aux route in a nested route there is no way to enable this aux-component. Having this config:
[
{path: 'dashboard', component: DashboardComponent},
...
{path: 'tasks', component: TasksComponent,
children: [
{path: '', component: TaskListComponent},
...
{path: 'overview/:id', component: TaskOverviewComponent, outlet: "right"},
]
},
and this code in TasksComponent html:
<div id="left">
<router-outlet></router-outlet>
</div>
<div id="right">
<router-outlet name="right"></router-outlet>
</div>
I can’t find a way to activate the right routeroutlet. I tried the following links:
http://localhost:4200/tasks(right:overview/1)
http://localhost:4200/tasks(right:./overview/1)
http://localhost:4200/tasks(right:/tasks/overview/1)
but no matter what I try I get:
Cannot match any routes: 'overview/1'
Cannot match any routes: './overview/1'
Cannot match any routes: '/tasks/overview/1'
What is the expected behavior?
It should be able to activate the aux-route
What is the motivation / use case for changing the behavior?
To be able to define aux-routes in nested routes, to be able to encapsulate all behaviour related to a use-case (“Tasks” in my case) in a dedicated module
Please tell us about your environment:
- Angular version: current master (57473e72ec303e1e5b29cd717287755cd8a725a7)
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
- Language: [all | TypeScript X.X | ES6/7 | ES5 | Dart]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:18 (3 by maintainers)
Top Results From Across the Web
angular - Use auxiliary routes in nested child components
I'm using Angular 2.1.2 with Router 3.1.2. parent.module import { NgModule } from '@angular/core'; ...
Read more >Angular Router: Child Routes, Auxiliary Routes, Master Detail
We will cover both child and auxiliary routes, and we will learn how to setup the very commonly used Master Detail routing scenario....
Read more >Angular Nested Auxiliary Routes (forked) - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >RouterOutlet - Angular
Emits an attached component instance when the RouteReuseStrategy ... The router keeps track of separate branches in a navigation tree for each named...
Read more >Working with Angular 14 Router - Techiediaries
How to import the necessary Angular built-in APIs to implement component routing and navigation,; How to create the routing module and ...
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
This is what I’m doing, and it seems to work.
And my routerLink to use the right-panel which is placed in template of the “contracts” component.
[routerLink]="{outlets: {'right-panel':'contract/'+model.id}}"
Additionally, this also, allows the navigation by path:
Hopefully this his helpful. It was a serious pain in the neck to actually figure out how to get this working. It REALLY needs to be documented somewhere official.
This has been causing me pain for the last day, so here is a Plunkr demonstrating how to navigate to an auxiliary child route:
http://plnkr.co/edit/N1BxbCn3ZR8yd0lnHZBU?p=preview
The important thing to note (because of #10726) is that your parent path cannot be blank.