我是否可以将辅助router-outlet
放入AppComponent
以外的任何其他组件中?因为目前当我这样做并尝试使用[routlerLink]
激活它时,我在控制台中收到错误,抱怨它无法找到名为popup的插座。如果我将它移回AppComponent
它就可以了!
所以这是我项目的结构:
app/
├──auth/
│ └──login/
│ └──login.component.ts/html/scss
├──landing/
│ ├──landing.module.ts
│ ├──landing.routing.ts
│ └──landing.component.ts/html/scss
├──app.module.ts
├──app.routing.ts
└──app.component.ts/html/scss
以下是相关代码(landing.routing / landing.component.html):
const routes: Routes = [{
path: '',
component: LandingComponent,
children: [{
path: 'login',
component: LoginComponent,
outlet: 'popup'
}]
}];

<p>
<a [routerLink]="[{ outlets: { popup: ['login'] } }]">Login</a>
</p>
<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
&#13;
...最后是app.routing.ts路线:
const routes: Routes = [
{ path: 'landing', loadChildren: 'app/landing/landing.module#LandingModule' },
{ path: '', component: HomepageComponent, canActivate: [AuthGuard] },
{ path: '**', component: NotFoundComponent }
];
&#13;