2017-05-04 30 views
0

如果我有兩個內容的邊欄,我如何使用路由,如果它在相同的層次結構,但不在相同的元素?Angular2使用2個側邊欄與路由

我想我不能使用其他<router-outlet>的側邊欄,因爲他們是不一樣的和不應該顯示相同的內容
我找不出我應該怎麼得到這個工作。

我想正好有左邊與容器展示內容A和右側邊欄上的容器的側邊欄顯示內容B

這是我app.routing.ts文件

const APP_ROUTES: Routes = [ 
    { path: '', redirectTo: '/Roulette', pathMatch: 'full' }, 
    { path: 'Roulette', component: RouletteComponent }, 
    { path: 'Jackpot', component: JackpotComponent }, 
    { path: 'Dice', component: DiceComponent }, 
    { path: 'Crash', component: CrashComponent }, 
    { path: 'Bingo', component: BingoComponent }, 
    { path: 'Chat', component: ChatComponent }, 
    { path: 'Account', component: AccountComponent } 
] 

回答

0

你可以考慮使用命名的路由器出口

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

和路由使用它像下面,

{ 
    path: 'Chat', 
    component: ChatComponent, 
    outlet: 'awesome' 
} 

瞭解更多關於Displaying multiple routes in named outlets here.

入住這Plunker!!

希望這有助於!

+0

等待,實際上工作?所以我可以在同一個component.html中使用3個插座?哇,很好,謝謝你,我現在會嘗試一下,如果我能正常工作,請給我反饋。非常感謝! – Prototype

+0

@Prototype,增加了一個Plunker的例子,乾杯! –

+0

工程就像一個魅力!非常感謝!拯救了我的一天和很多令人頭疼的時刻:) – Prototype