2017-08-28 206 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显然没地方有...