2016-12-16 66 views
0

嵌套路由我的路由配置如下角-2兩級

export const ProductRoutes: Route[] = [ 
    { 
    path: 'product/:api_key', 
    component: ProductComponent, 
    children:[ 
     { 
      path: 'productType', component: productTypesComponent, 
     //  children:[ 
      //  { path: 'productEntry', component: productEntriesComponent } 
      // ] 
     }, 
    ], 
    canActivate: [CanActivateService] 
    } 
]; 

它適用於兒童路線的一個水平,但是當我添加第二個級別的子productEntry它停止工作,即使我的路由器配置顯示正確的孩子順序。

任何有用的資源,將不勝感激。由於

+0

你得到任何錯誤? – ranakrunal9

+0

請確保您已在第二級子級(productTypesComponent)上添加了router-outlet標記。 –

+0

我收到錯誤:無法匹配任何路線:「產品/ blt1b502f126e0ddf02/productType」 .. 它的作品,如果我評論productEntry –

回答

0

你試圖添加一個空的路徑:

children:[ 
    { path: '', redirectTo: 'productEntry' } 
    { path: 'productEntry', component: productEntriesComponent } 
] 
+0

任何具體的原因做到這一點... –