angular - 在 Angular 中使用 Route 导航到特定页面
问题描述
我想使用 Angular 提供的路由显示一个页面,如果 minType = mino 在我的路由文件中,有必要转到路由中声明的另一个组件,这可能吗?
我需要使用 Childs 路线吗?或者在 ts 文件中执行if() ?
谢谢你。
路由
const minRoutes: Routes = [
{
path: min/:id/:mineType,
component: MinComponent,
}
]
ts.文件
getDataFromRoute() {
this.route.paramMap.subscribe((params:Params) => {
this.id = params.get('id');
this.type = params.get('mineType');
}
}
解决方案
我认为你可以使用这条路线:
const minRoutes: Routes = [
{
path: min/mino/:id,
component: AnotherComponent,
},
{
path: min/:mineType/:id,
component: MinComponent,
}
]
推荐阅读
- algorithm - 树贪婪方法的顶点覆盖
- java - 带有 Java 8 lambda 和 Optional 的子类
- c++ - 由于从 float 自动转换为 double 导致的 nan-boxing 的 std::num_put 问题
- java - 尝试检索特定路径下的文件夹/文件的 CMIS 查询不返回任何文档
- excel - cell.Value 未检索单元格中的回车符
- php - 指定为 so 时 PHP 会话不会取消设置数组项
- java - Log4j2/Slf4j 和 Java 11
- java - 没有 XML 类映射的 Hibernate-JPA
- angular - 使用'as'语法的可观察数组的长度
- qt - 如何在启动时绘制 QLines?