Skip to content

unable to create a redirect for named outlet #33783

Closed

Description

@aquark

🐞 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       
@angular-devkit/build-angular   0.802.2
@angular-devkit/core            
@angular-devkit/schematics      
@angular/cdk                    7.3.7
@angular/cli                    8.3.17
@angular/material               7.3.7
@schematics/angular             
@schematics/update              
rxjs                            6.5.3
typescript                      3.5.3
webpack                         4.38.0

Anything else relevant?
Nope.

Activity

  1. added this to the needsTriage milestone on Nov 13, 2019
  2. modified the milestones: needsTriage, Backlog on Nov 20, 2019
  3. added
    P4
    and removed on Oct 1, 2020
  4. mduft commented on Jun 7, 2022

    @mduft

    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:

    const ADMIN_ROUTES: Route[] = [
      {
        path: '',
        pathMatch: 'full',
        redirectTo: 'all',
      },
      {
        path: 'all',
        component: AdminShellComponent,
        children: [
          { path: '', pathMatch: 'full', redirectTo: 'general', outlet: 'admin' },
          {
            path: 'general',
            component: SettingsGeneralComponent,
            canDeactivate: [DirtyDialogGuard],
            outlet: 'admin',
          },
    ...
    

    we had to replace this with:

    const ADMIN_ROUTES: Route[] = [
      {
        path: '',
        pathMatch: 'full',
        redirectTo: '/admin/all/(admin:general)',
      },
      {
        path: 'all',
        component: AdminShellComponent,
        children: [
          {
            path: 'general',
            component: SettingsGeneralComponent,
            canDeactivate: [DirtyDialogGuard],
            outlet: 'admin',
          },
    ...
    

    (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'...

  5. Talb2005 commented on Oct 2, 2022

    @Talb2005

    Any progress with this issue?

  6. pixeldublu commented on Oct 30, 2022

    @pixeldublu
    Contributor

    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 🤞

  7. added a commit that references this issue on Oct 31, 2022
    b2dffb9
  8. mduft commented on Nov 2, 2022

    @mduft

    Very nice, thanks. Will try this once I have time :| ;)

  9. added 2 commits that reference this issue on Nov 4, 2022
    db867fe
    b8a6f74
  10. added a commit that references this issue on Nov 11, 2022
  11. angular-automatic-lock-bot commented on Dec 5, 2022

    @angular-automatic-lock-bot

    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.

  12. locked and limited conversation to collaborators on Dec 5, 2022
  13. added a commit that references this issue on Feb 1, 2023
    48a4f87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions