javascript - 为延迟加载的模块组件指定 routerLink?
问题描述
在这个演示应用程序中,我在延迟加载的书籍模块中有以下路线:
{ path: 'collection', component: CollectionPageComponent },
在搜索组件中,以下路由器链接:
<a routerLink="collection">Collections</a>
将鼠标悬停在链接上时,它会显示路径books/collection
。但是,当单击它时,它会路由到 404 页面。想法?
https://stackblitz.com/edit/angular-temp-slice-demo-phase2?file=src%2Fapp%2Fbooks%2Findex.ts
解决方案
路线
{ path: ':id', component: ViewBookComponent, resolve: { book: BookResolverService }}
正在使用您的字符串collection
作为id
.
为了解决这个问题,
将特定路线放在顶部,即
{ path: 'collection', component: CollectionPageComponent },
{ path: ':id', component: ViewBookComponent, resolve: { book: BookResolverService }}
推荐阅读
- homebrew - 尝试使用自制软件下载 nvm 时出错
- angular - Angular 指令标签搞乱了 Bootstrap 布局
- c++ - 进程运行时是否可以使用进程输出?
- .net - 在 xaml 中显示当前区域性小数分隔符
- javascript - react组件的执行顺序
- python - 不使用 if-else 的条件参数?
- angular - Angular Eslint config is not extending Project Eslint config
- python - 使用多处理时结合 Pandas DataFrames
- python - 无论如何使用带有 python GUI 框架的 Windows UI 库
- terraform - 创建谷歌云存储桶并使用相同的 terraform 脚本将 terraform 状态保存到其中?