2016-10-20 30 views
1

Layout for all users兩個主要的路由器,網點用不同的佈局

Layout for personnel (like admin control panel)

我有一個router-outlet其中有第一個佈局。在/personnel我想用第二個。怎麼做?我不想隱藏元素,因爲personnel也很喜歡personnel/users

成分,我想加載personnel作爲獨立的組件,它不是主要router-outlet內。 personnel應該有它自己的router-outlet

讓我們更清楚一點。

const appRoutes: Routes = [ 
    { // first layout (here is the first and for now the only one router-outlet 
    path: '', 
    children: [ 
     { path: '', component: SiteComponent, pathMatch: 'full' }, 
     { path: 'install', component: InstallationComponent, canActivate: [ InstallationAuth ] }, 
     { path: 'login', component: LoginComponent, canActivate: [ LoginAuth ] }, 
     { path: 'register', component: RegisterComponent }, 
     { path: 'reset', component: ResetComponent, canActivate: [ LoginAuth ] } 
    ] 
    }, 
    { //second layout (personnel should have it's own router-outlet 
    path: 'personnel', 
    children: [ 
     { path: '', component: PersonnelComponent, canActivate: [ PersonnelAuth ]}, 
     { path: 'users', component: UsersComponent, outlet: 'personnel' } 
    ] 
    } 
]; 

回答

0

您可以一步向下移動你的潰敗層次結構,所以在你的根應用程序組件定義單一<router-outlet></router-outlet>沒有任何佈局,一步到位來與你的主要佈局定義默認爲空航線組件

<...LayoutMain> 
<router-outlet></router-outlet> 
<...LayoutMain>` 

在secon組件中定義您的人員佈局惠特/人員根

<...Layoutpersonnel > 
    <router-outlet></router-outlet> 
    <...Layoutpersonnel >` 
相關問題