angular - 使用一个模块的角度多个延迟加载的路由/路径
问题描述
我正在尝试配置几条水平路线(即 - 不嵌套)并将它们放入一个延迟加载的模块中。
问题是,我无法弄清楚如何在延迟加载的功能模块本身中匹配这些路由。
这是主路由模块的样子 -
{
path: 'search/:query',
loadChildren: () => import('src/pages/archives.module').then(m => m.ArchivesModule),
},
{
path: 'category/:category',
loadChildren: () => import('src/pages/archives.module').then(m => m.ArchivesModule),
},
{
path: 'tag/:tag',
loadChildren: () => import('src/pages/archives.module').then(m => m.ArchivesModule),
},
然后,在我的功能模块中,我试图根据路径匹配这些路由,但它不起作用 -
{
path: 'search/:query',
component: SearchComponent,
resolver: SearchResolver,
},
{
path: 'category/:category',
component: CategoryComponent,
resolver: CategoryResolver,
},
{
path: 'tag/:tag',
component: TagComponent,
resolver: TagResolver,
},
当我尝试完全访问重复的路由时,它确实有效,例如:
domain.com/category/:cat/category/:cat
所以我想唯一缺少的是一种在功能模块中匹配父路由的方法,但我在它周围找不到任何东西。
解决方案
The code structure is not clean. You are making a module that routes to another module using three routes. Why not removing the routes from the parent module, and just make them in the feature module. Parent Module:
{
path: '/',
loadChildren: () => import('src/pages/archives.module').then(m => m.ArchivesModule),
}
Feature Module:
{
path: 'search/:query',
component: SearchComponent,
resolver: SearchResolver,
},
{
path: 'category/:category',
component: CategoryComponent,
resolver: CategoryResolver,
},
{
path: 'tag/:tag',
component: TagComponent,
resolver: TagResolver,
},
推荐阅读
- python - Flask SQLAlchemy 找不到相关的类
- numpy - Numpy向量化:将上面的行添加到ndarray上的当前行
- java - 使用 startMonitoringBeaconsInRegion 发生致命崩溃
- spring - Spring Mvc 控制器获取端点不重定向
- oauth-2.0 - B2C 自定义策略跳过通过 authenticationSource 注册 AAD 以 AADB2C90037 结束
- r - 使用 dplyr 而不是 lapply
- c - 大文件上 fscanf 的分段错误
- angular - Angular CanDeactivateGuard:如何等待 Obersavble 的正确值或下一个值?
- javascript - HTMLAudioElement.currentTime 不是函数
- json - Aeson 使用先前解析的默认值解析 JSON