【发布时间】:2019-12-07 06:36:58
【问题描述】:
我有一个路由/组件,它需要一个路由参数并且有一个命名的出口。我想延迟加载一个模块并激活这条路线。这是我的路线:
Profile Module(子模块)Routes:
const routes: Routes = [
{
path: ':id', component: ProfileComponent
children: [
{ path: 'list/:id', component: ListComponent, outlet: 'sidebar' },
{ path: 'risk/:id', component: RiskComponent, outlet: 'sidebar' }
],
];
父模块路由
const routes: Routes = [
{ path: 'projects/profile',
loadChildren: './profile/profile.module#ProfileModule' }
]
加载路由报错:
错误:无法匹配任何路由。 URL 段:'projects/profile/-3'
当我在子模块中使用空字符串作为路径时,没有错误并且模块加载但组件不加载。我发现 this help 使用延迟加载路由参数,this help 使用延迟加载命名路由器出口,但都没有工作。
我的问题是: 如何延迟加载带有路由参数和命名路由器出口的路由?
--编辑--
这是一个demo app,它显示了我的问题。我创建了 3 条主要路线:一种延迟加载没有命名插座的子模块,一种延迟加载带有命名插座,另一种不使用延迟加载。在 UI 中,指向具有命名出口的路由的链接会产生上述错误。
【问题讨论】:
标签: angular