2017-08-28 203 views
0

我有一個懶惰的加載組件,並且我有一個路由問題。Angular 4延遲加載路由 - 兒童不加載

的路線是這樣的:

const routes: Routes { 
     {path: '': component: ReportsComponent, children:[ 
     {path: '', component: DeviceReportComponent}, 
     {path: 'sites', component: SiteReportComponent}, 
     {path: 'devices', component: DeviceReportComponent} 
     ]} 
    } 

現在,當我瀏覽到組件,第一路由負載完美,但在這之後的任何企圖導航忽略。

有什麼想法?

+1

在你正在向你展示拼寫錯誤的'children'的代碼,複製粘貼時這只是一個錯字嗎? – Philipp

+0

輸入此錯誤時,系統處於未連接到互聯網的專用網絡 – idekkers

回答

0

我可以想象,有兩個空路徑路由到兩個不同的組件會導致問題。 this training表明,根空路徑總是路線與組件具名的路線:

export const routes: Routes = [ 
    { path: '', redirectTo: 'product-list', pathMatch: 'full' }, 
    { path: 'product-list', component: ProductList }, 
    { path: 'product-details/:id', component: ProductDetails, 
    children: [ 
     { path: '', redirectTo: 'overview', pathMatch: 'full' }, 
     { path: 'overview', component: Overview }, 
     { path: 'specs', component: Specs } 
    ] 
    } 
]; 

你可以試着堅持該模板。

+0

這是一個延遲加載路由,並且子節點在子路由器中 – idekkers

0

確定

後的代碼一些挖掘,發現錯誤: 在主路由器,我只好報告/:類型,其中:TYPE顯然沒地方有...