Angular2 router - Auxiliary route

∥☆過路亽.° 提交于 2019-12-23 21:41:25

问题


I do have a lazy loaded module which loads by default LazyLoadedComponent when I go to /lazy. So far, it's OK.

This component contains 2 router-outlet :

<router-outlet></router-outlet>
<router-outlet name="aux"></router-outlet>

And the module has the following routes :

const routes = [
  {
    path: '',
    component: LazyLoadedComponent,
    children: [
      {
        path: '',
        component: NonAuxComponent
      },
      {
        path: '',
        component: AuxComponent,
        outlet: 'aux'
      }
    ]
  }
];

When I go to /lazy I do have the 3 components loaded as expected. But, if I want to change the path to display the AuxComponent like that :

{
   path: 'auxpath',
   component: AuxComponent,
   outlet: 'aux'
}

And I try to go to /lazy(aux:auxpath) it's not working.

I also tried to hit that url using the routerLink like that :

<a [routerLink]="[{ outlets: { aux: 'auxpath' } }]">Load an auxiliary route</a>

But it's not working either.

Is this a bug with the router ? Is it just me missing out something here?

You can check out the Plunkr to make your own tests.


回答1:


After trying a lot of things, I ended up with the conclusion that it was probably a bug in @angular/router.

I created a Github issue, and it turns out that one was already existing since august.



来源:https://stackoverflow.com/questions/41495093/angular2-router-auxiliary-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!