Skip to content

bug(router) aux-routes not working with empty-path top-level routes #10726

Closed

Description

@choeller

I'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

Aux-Routes are not found when using two levels of "default routes" (with path:'').
This config works:

 RouterModule.forRoot([
      {
        path: 'tasks', component: TasksComponent, //container-component has two outlets! 
        children: [
          { path: '', component:TaskListComponent },
          { path: 'overview/:id', component: TasksComponent, outlet: 'right' },
        ]
      }
  ],

I can open the Tasks-overview by doing:

http://localhost:4200/tasks/(right:overview/3)

See this plnkr and click "to list", "open aux"

As I want to extract the whole Tasks-Functionality into a TasksModule I need to be able to do something like this:

 RouterModule.forRoot([
      {
        path: 'tasks', : children: [ // this one would be in main module
          //this is defined in the TasksModule:
          { path: '', component: TasksComponent, //container-component has two outlets! 
            children: [
              { path: '', component:TaskListComponent },
              { path: 'overview/:id', component: TasksComponent, outlet: 'right' },
          ]
      }
  ],

I would assume both configs are equivalent, and all of the "normal" routing works perfectly fine. But now the link above http://localhost:4200/tasks/(right:overview/3) leads to:

Uncaught (in promise): Error: Cannot match any routes: 'tasks'

See this plnkr: http://plnkr.co/edit/xd77Mkpqfq6U9tKM4USU?p=preview

Expected/desired behavior

Aux-Routes should also work with empty-path parents

Reproduction of the problem

Working version: http://plnkr.co/edit/Twx4hXQ0TLfHfrYSe4MO?p=preview
Non-working version: http://plnkr.co/edit/xd77Mkpqfq6U9tKM4USU?p=preview

What is the expected behavior?

Both versions of route definition should lead to the same behavior

What is the motivation / use case for changing the behavior?

With the current implementation it is impossible to create an encapsulated Config / Module for the tasks behaviour and include it under a certain path into the main config e.g. "myTasks".

/cc @vsavkin

Please tell us about your environment:

  • Angular version: 2.0.0-rc.5
  • Browser: [all ]
  • Language: [TS ]

Activity

  1. changed the title [-]bug(router) aux-routes not working with componentless top-level routes[/-] [+]bug(router) aux-routes not working with empty-path top-level routes[/+] on Aug 14, 2016
  2. choeller commented on Aug 25, 2016

    @choeller
    ContributorAuthor

    @vsavkin are there plans to fix this? I think the current behaviour makes it impossible to use aux-routes in combination with lazy-loading / feature-module scenarios

  3. self-assigned this
    on Nov 1, 2016
  4. removed their assignment
    on Nov 16, 2016
  5. sambaek commented on Nov 30, 2016

    @sambaek

    Any updates on this? This is blocking us from building out a feature. Would love to see this fixed or a proposed workaround

  6. jeanpaulattard commented on Jan 31, 2017

    @jeanpaulattard

    I have also encountered this issue, and is blocking me from performing certain actions... @vsavkin what are the plans concerning this issue? Are there any plans of tackling it in the near or distant future?

    Thanks in advance!

  7. mikechamberlain commented on Feb 26, 2017

    @mikechamberlain

    Yeah this one is really frustrating! I've just spent the last day trying to figure out why my child auxiliary route doesn't work as expected, and have finally tracked it down to this bug. Would be great to have some kind of ETA on this.

    In case anyone is interested, here is a Plunkr with the workaround implemented, demonstrating how to load child aux routes both from a routerLink and programatically.

    http://plnkr.co/edit/N1BxbCn3ZR8yd0lnHZBU?p=preview

  8. uberspeck commented on Feb 26, 2017

    @uberspeck

    I'd love to see this fixed soon as well! Burned through a day and a half of beating my head against the wall before giving up and falling back to Bootstrap modals. I do love this router though!

  9. dietergeerts commented on Mar 17, 2017

    @dietergeerts

    This needs to be fixed ASAP!!! Some resolves are common for the main component and the auxiliary one, so they HAVE to be declared one level higher, without a path!

  10. asadsahi commented on Mar 31, 2017

    @asadsahi

    @IgorMinar @pkozlowski-opensource appologies to attract your attention to this issue. Any ETA on this one?

  11. jcimoch commented on May 26, 2017

    @jcimoch

    I spent hours figuring out why it is not working and then I found this bug. It is still not working on angular 4.0.3 :(

  12. 57 remaining items

  13. jcimoch commented on Jan 5, 2021

    @jcimoch

    Sooner than covid-19 vaccine, I can't believe it!

  14. Bulforce commented on Jan 5, 2021

    @Bulforce

    ⭐⭐⭐⭐⭐
    👏👏👏👏👏

    Feels like xmas :)

  15. henriacle commented on Jan 5, 2021

    @henriacle

    Finally, gonna try it tomorrow 2021 is already a promising year 🥳🤣

  16. added a commit that references this issue on Jan 5, 2021
    f542e4e
  17. atscott commented on Jan 6, 2021

    @atscott
    Contributor

    This is was included in the 11.0.6 release today so if you're able to update your applications, please do and give it a go.

  18. acohenOT commented on Jan 8, 2021

    @acohenOT
    Contributor

    Works great. Thank you @atscott !

  19. LukasMachetanz commented on Jan 19, 2021

    @LukasMachetanz

    I am not sure, but maybe another bug was introduced with this MR. Or at least not fixed. It seems that router.isActive does not provide the correct result for auxiliary routes with empty-path top level routes.

    I tried it here: https://stackblitz.com/edit/lukmac-angular-router

    I think the example should be self explanatory. I would expect the console output to show true and not false.

    Can maybe someone confirm the issue and tell if it is somehow corresponding to this. Thanks.

  20. angular-automatic-lock-bot commented on Feb 19, 2021

    @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.

  21. locked and limited conversation to collaborators on Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions