2017-06-01 93 views
1

這是我的路由組件。基本上我路由的出口到html標籤導航到兄弟兒童路由器插座不工作

目前我在交易頁面 - > TransactionsComponent選項卡(單個)。

<a [routerLink]="['../Product',{outlets :{ }}]"></a>

我不知道什麼如何應該是routerlink上方導航到FridgeComponent - >「冰箱」直接出口。我嘗試了不同的選擇,都沒有工作。

請建議實現此目的的方式。

export const ROUTES: Routes = [ 
    { path: '', redirectTo:'home', pathMatch: 'full'}, 
    { path: 'home', component: HomeComponent, 
     children:[ 
     { 
      path :'', 
      component: HomeOneComponent, 
      outlet:'one'}, 
     { 
      path :'', 
      component: HomeTwoComponent, 
      outlet:'two' 
     } 
    ]}, 
    { 
     path: 'Product', 
     component: ProductComponent, 
     children:[ 
      {path :'', component: TVComponent, outlet:'tv'}, 
      {path :'', component: ACComponent, outlet:'ac'}, 
      {path :'', component: FridgeComponent, outlet:'fridge'} 
      ] 

    }, 
    { 
     path: 'Transactions', 
     component: TransactionsComponent 
    } 
]; 

回答

0

這應該爲你工作,你必須在你的路由的值賦給路徑,即使是孩子的路線。

......... 
{ 
    path: 'Product', 
    component: ProductComponent, 
    children:[ 
     {path :'tv', component: TVComponent, outlet:'tv'}, 
     {path :'ac', component: ACComponent, outlet:'ac'}, 
     {path :'fridge', component: FridgeComponent, outlet:'fridge'} 
     ] 

}, 
........ 

而在HTML routerLink,確保ü提出口名稱和路徑名

<a [routerLink]="['/product', {outlets: {'fridge': ['fridge']}}]">     
</a> 

如果你仍然看到困難,請分享Github上/ plunker。

+0

提供路徑值將工作。但我不想顯示每個組件的路徑。由於孩子們是標籤的一部分。有沒有提供路徑的方式? – Sanjaybxl