Router named outlet in child route of an empty path doesn't work
See original GitHub issueπ bug report
Affected Package
The issue is caused by package @angular/routerIs this a regression?
NoDescription
I have a route with empty path, and in it's children I would like to define a named outlet route in the following way.{
path: '',
children: [
{
path: 'mywidget',
component: MyWidgetComponent,
outlet: 'widget',
},
{
path: '',
component: MainPageComponent,
}
]
},
{
path: 'other',
component: OtherPageComponent
},
This config fails with the following error.
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'mywidget'
Error: Cannot match any routes. URL Segment: 'mywidget'
Giving a path name to the parent route solve the problem, but I would like to use an empty path there because itβs a default route.
{
path: 'main',
children: [
{
path: 'mywidget',
component: MyWidgetComponent,
outlet: 'widget',
},
{
path: '',
component: MainPageComponent,
}
]
},
{
path: 'other',
component: OtherPageComponent
},
π¬ Minimal Reproduction
Not working: https://stackblitz.com/edit/angular-named-outlet-empty-path
And this is the fix that Iβm trying to avoid: https://stackblitz.com/edit/angular-routing-child-named-outlet
π₯ Exception or Error
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'mywidget'
Error: Cannot match any routes. URL Segment: 'mywidget'
at ApplyRedirects.noMatchError (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/@angular/router@7.1.3/bundles/router.umd.js:2557:20)
at CatchSubscriber.eval [as selector] (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/@angular/router@7.1.3/bundles/router.umd.js:2538:33)
at CatchSubscriber.error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/catchError.js:48:31)
at MapSubscriber.Subscriber._error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at TapSubscriber._error (https://angular-named-outlet-empty-path.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/tap.js:75:26)
π Your Environment
Angular Version:
@angular-devkit/architect 0.7.5
@angular-devkit/build-angular 0.7.5
@angular-devkit/build-optimizer 0.7.5
@angular-devkit/build-webpack 0.7.5
@angular-devkit/core 0.7.5
@angular-devkit/schematics 0.7.5
@angular/cli 6.1.5
@angular/platform-server 7.0.2
@ngtools/webpack 6.1.5
@schematics/angular 0.7.5
@schematics/update 0.7.5
rxjs 6.3.3
typescript 2.7.2
webpack 4.9.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:29
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Load child route of route with an empty path into a named outlet
I have a route with an empty path that acts as a guard for all the other components in my application. Its children...
Read more >Angular Router: Child Routes, Auxiliary Routes, Master Detail
This is a comprehensive guide to the fundamental concepts of the Angular Router: routes, paths, components, outlets.
Read more >Defining Child Routes - Rangle.io : Angular Training
Since the Overview child route of product-details has an empty path, it will be loaded by default. The specs child route remains the...
Read more >Andrei GΔtej
children 's values are named outlets and their segments. All the UrlSegmentGroup.segments are consumed and UrlSegmentGroup.children is empty:.
Read more >Common Routing Tasks - Angular
The application name in the following example is routing-app . ... List routes with a static path first, followed by an empty path...
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
Just as as reminder, this closed duplicate #10726 had 88 votes!
Still an issue in 2020.