Angular 具有异步子路由器的命名路由器出口
我在Angular 6.1.0项目中工作 我需要在“应用组件”中的一个区域(名为路由器出口)中加载另一个配置了异步路由器的组件 在版本6.1.0的变更日志中,它显示: 路由器:修复辅助路由的延迟加载(#23459)(5731d07),关闭# 10981 在我的项目中,此选项不起作用: 根路由器配置:Angular 具有异步子路由器的命名路由器出口,angular,router,router-outlet,Angular,Router,Router Outlet,我在Angular 6.1.0项目中工作 我需要在“应用组件”中的一个区域(名为路由器出口)中加载另一个配置了异步路由器的组件 在版本6.1.0的变更日志中,它显示: 路由器:修复辅助路由的延迟加载(#23459)(5731d07),关闭# 10981 在我的项目中,此选项不起作用: 根路由器配置: const routes: Routes = [ { path: "products", component: ProductListComponent }, { path: "produc
const routes: Routes = [
{ path: "products", component: ProductListComponent },
{ path: "product/:id", component: ProductDetailComponent },
{
path: "",
component: SidebarComponent,
outlet: "sidebar"
},
{
path: "products",
component: ProductListSidebarComponent,
outlet: "sidebar"
},
{
path: "tests",
loadChildren: "app/test-async/test.async.module#TestAsyncModule"
}
];
export const routingModule: ModuleWithProviders = RouterModule.forRoot(routes);
测试异步模块(路由器配置)
应用程序组件(模板)
如果在没有异步负载的情况下直接配置路由,则链路将以正确的方式运行
在这里,我在项目中留下了一个沙盒,以便您可以看到错误
有什么建议吗
编辑:2018年8月8日
如果我更改以下项目的根配置:
{
path: "tests",
loadChildren: "app/test-async/test.async.module#TestAsyncModule"
outlet: 'sidebar'
}
在模块路由中,我更改为:
{
path: '',
component: TAsyncComponent,
}
路由工作
但是。。。。我强制在异步加载模块中定义的所有路由在某个区域中呈现,而不是路由可以决定父节点中定义的区域。(导入模块)
可能这是一个概念问题,路由是分层的,向下可访问,不允许访问在层次结构中较高级别定义的路由
有人能澄清一下吗?
概念问题?或者,这是不是角度布线中缺少的东西
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'tests'
Error: Cannot match any routes. URL Segment: 'tests'
at ApplyRedirects.noMatchError (router.umd.js:1455)
...
{
path: "tests",
loadChildren: "app/test-async/test.async.module#TestAsyncModule"
outlet: 'sidebar'
}
{
path: '',
component: TAsyncComponent,
}