子组件中的辅助路由器 - outlook

时间:2017-04-26 17:34:42

标签: angular router-outlet

我是否可以将辅助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;
&#13;
&#13;

...最后是app.routing.ts路线:

&#13;
&#13;
const routes: Routes = [
    { path: 'landing', loadChildren: 'app/landing/landing.module#LandingModule' },
    { path: '', component: HomepageComponent, canActivate: [AuthGuard] },
    { path: '**', component: NotFoundComponent }
];
&#13;
&#13;
&#13;

0 个答案:

没有答案