[英]Angular 4 lazy load routing - children not loading
I have a lazy load component, and I have an issue with routing inside of it. 我有一个延迟加载组件,并且内部路由存在问题。
the routes look like this: 路线如下所示:
const routes: Routes {
{path: '': component: ReportsComponent, children:[
{path: '', component: DeviceReportComponent},
{path: 'sites', component: SiteReportComponent},
{path: 'devices', component: DeviceReportComponent}
]}
}
now when I navigate to the component, the first route loads perfectly, but any navigation attempt after that is ignored. 现在,当我导航到该组件时,第一条路线会完美加载,但此后的任何导航尝试都将被忽略。
any ideas? 有任何想法吗?
I can imagine that having two empty paths routing to two different component would cause problems. 我可以想象有两个空路径路由到两个不同的组件会导致问题。 this training shows that the root empty path always routes to a named route with a component:
此训练表明,空根目录始终会路由到具有组件的命名路由:
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 }
]
}
];
You could try to stick to that template. 您可以尝试坚持使用该模板。
ok 好
after some digging in the code, found the error: in the main router, I had reports/:type , where the :type obviously had no place there... 在仔细研究代码后,发现了错误:在主路由器中,我有report /:type,其中:type显然在那里没有位置...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.