Angular2 router - Auxiliary route

2019-07-05 07:03发布

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.

enter image description here

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条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-07-05 07:32

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.

查看更多
登录 后发表回答