unable to create a redirect for named outlet
See original GitHub issue🐞 bug report
Affected Package
The issue is caused by package @angular/router
Is this a regression?
Unsure.
Description
I have a named router outlet which I want to default by redirecting the empty path to one of the named paths, e.g.
{ outlet: 'test', path: '', pathMatch: 'full', redirectTo: 'default' },
{ outlet: 'test', path: 'default', component: TestComponent },
This worked when the configuration was in a lazy loaded module, however moving it to the root router configuration now fails to validate. This configuration seems like it should be valid. The only workaround I could find was to use an absolute path, e.g.
{ path: 'test', pathMatch: 'full', redirectTo: '/test/(test:default)' },
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-issue-repro2-fikqg2
🔥 Exception or Error
Error: Invalid configuration of route 'test/': a componentless route without children or loadChildren cannot have a named outlet set
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.3.17
Node: 12.4.0
OS: darwin x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect <error>
@angular-devkit/build-angular 0.802.2
@angular-devkit/core <error>
@angular-devkit/schematics <error>
@angular/cdk 7.3.7
@angular/cli 8.3.17
@angular/material 7.3.7
@schematics/angular <error>
@schematics/update <error>
rxjs 6.5.3
typescript 3.5.3
webpack 4.38.0
Anything else relevant? Nope.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Angular 2: How to redirect route to child route with named outlet
My issue was this error 'Only absolute redirects can have named outlets.' Since the angular named outlet URL is not desired, ...
Read more >Route - Angular
Supports static, parameterized, redirect, and wildcard routes, as well as custom ... The following route creates sibling components with multiple outlets.
Read more >Multiple Router Outlets in Angular using Named Outlets (2021)
Multiple Router Outlets in #Angular allow you to manage complex router states, allowing you to fork your router into multiple active paths ...
Read more >Angular Router Series: Secondary Outlets Primer - InDepth.Dev
In this short article, we're going to explore secondary outlets (sometimes called named router outlets), and see the role they play in routing....
Read more >Chaining Absolute And Local Redirects With The Router In ...
This is because the Angular Router won't follow the local "list" redirect after it has followed the absolute "/people" redirect. As such, any ......
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
After updating to Angular 14, I got this error for our router configuration. It seems that this was possible all the way from Angular 9 to 13, but no longer for 14:
we had to replace this with:
(note that the default redirect for the ‘admin’ panel moved from the children to the outer (main) redirect).
this works nearly as well (for us), since we’re never directly navigating to /all, but always to (empty), so the default redirect will also redirect the ‘admin’ outlet correctly. However if a user manually navigates to the /admin/all route without outlet, this will now no longer correctly set the ‘admin’ outlet to ‘general’…
I also discovered this issue a few days ago after upgrading. Since there was no activity I decided to create a pull request on this. ( #47921 )
Hopefully gets in soon 🤞