Skip to content

ERROR: router cannot match any routes in child component named router-outlet #14896

Closed

Description

@denisyilmaz

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] 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
I have a module with two router-outlets. The main outlet and one named 'side_menu'.
In the module I have following routes:

RouterModule.forChild([{
  path: ':lang',
  component: PageComponent,
  children:  [{
      path: '',
      component: MainComponent
  },{
      path: 'imprint',
      children: [{
        path: '',
        component: MainComponent
      },{
        path: '', // THIS ONE WORKS ( example.com/en/imprint)
        component: SideMenuComponent,
        outlet: 'side_menu'
      }]
  },{
      path: ':any',
      component: MainComponent
  },{
      path: 'imprint', // THIS ONE DOENST WORK ( example.com/en/anypage(side_menu:imprint) )
      outlet: 'side_menu',
      component: SideMenuComponent
  }]
}])

when navigating to example.com/en/imprint the app correctly activates PageComponent with MainComponent in the router-outlet and SideMenuComponent in the "side_menu" router-outlet.
But: when I navigate for example toexample.com/en/anypage(side_menu:imprint) I get Error: Cannot match any routes. URL Segment: 'imprint'

Expected behavior
That I can show the "side_menu" router-outlet no matter which other views are currently active.

Minimal reproduction of the problem with instructions
http://plnkr.co/edit/e8lUPmvni1LgWCKilz6t?p=preview

What is the motivation / use case for changing the behavior?
having an overlay that can be displayed and hidden based on params and without changing the current visible main view

Please tell us about your environment:
macOS Sierra, Visual Studio Code, Safari, Chrome

  • Angular version: 4.0.0-rc.1
    Angular Quickstart Master Seed updated to @angular ">=4.0.0-beta <5.0.0" and typescript "~2.1.0"

  • Browser:
    tested in Chrome & Safari

Activity

  1. changed the title [-]cannot match any routes of named router-outlet as childmodule[/-] [+]ERROR: router cannot match any routes in child component named router-outlet[/+] on Mar 4, 2017
  2. denisyilmaz commented on Mar 12, 2017

    @denisyilmaz
    Author

    any updates or suggestions? can't figure it out how to get this to work. or is this by design?

  3. miguelnavarro89 commented on Jun 22, 2017

    @miguelnavarro89

    same for me, not working.

  4. southeastcon2017 commented on Jun 25, 2017

    @southeastcon2017

    @denisyilmaz Hi, not sure if this is the same issue, but might be worth a look, just in case.

    https://stackoverflow.com/questions/44741936/angular-4-multiple-named-router-outlets-in-a-child-route-supported/44742481

    The routerlink syntax wasn't behaving as I had initially expected.

  5. denisyilmaz commented on Jun 26, 2017

    @denisyilmaz
    Author

    actually changing the router-link to adding the /en in

    <a [routerLink]="[ -->'/en', <-- {outlets: {side_menu: ['imprint']}}]" title="show Sidemenu in named router-outlet">Show Sidemenu</a>

    get the auxiliary route to work.

    but I don't understand why this would be necessary?

    as the router-link is already in the active component (PageComponent) and showing the correct path /en(site_menu:imprint) (which will throw the error) i would guess it should work.
    changing like mentioned above the link is then /en/(site_menu:imprint) (and works)…

    --> shouldn't both solutions work?

  6. southeastcon2017 commented on Jul 8, 2017

    @southeastcon2017

    i would have thought so. which is why I created that stackoverflow question. documentation isn't very great for angular's secondary routing. i did pick up Victor Savkin's (the creator of the angular router) book "Angular Router", hopefully that helps.

  7. jasonaden commented on Dec 19, 2017

    @jasonaden
    Contributor

    Closing as resolved.

  8. jlberrocal commented on Jan 10, 2018

    @jlberrocal

    well it was not resolved it just have a workaround currently i'm facing a similar behavior, mi problem is that my routes are more dynamic so i can't just write my current route + the inner outlet

  9. dgroh commented on Feb 23, 2018

    @dgroh

    not resolved...there should be a way to have a fallback for not found outlets.

  10. jlberrocal commented on Feb 23, 2018

    @jlberrocal

    most probably this will only fails when using lazy loading, because router is not determining exactly where it's at the moment, however i was able to continue after using the property relativeTo, to the current route (ActivatedRoute), as i wrote before, my problem was that where i was planning to use the second router i have a dinamic param which will not allow me to set the route manually as @denisyilmaz did in his comment, after several expended hours this was the only workaround i found, not sure if will possible to make a fix for this, but seems to be more complicated than what i thought at the beggining

  11. dgroh commented on Feb 23, 2018

    @dgroh

    It's also gonna fail if you have multiple angular applications on a single app. Which was my case.
    Nevertheless I could solve this without using named outlets.

  12. angular-automatic-lock-bot commented on Sep 13, 2019

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

  13. locked and limited conversation to collaborators on Sep 13, 2019
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions