angular - 如何在 Angular 中检索夹层/内部 URL 参数?
问题描述
所以我的 url 路由是 'players/:id/listview'
(listview 是 objects 组件的子组件)
我的路由模块:
path: 'players/:id',
component: PlayersComponent,
children: [
{ path: '', redirectTo: 'listview' },
{ path: 'listview', component: ListviewComponent }
]
我试过了
this.route.snapshot.paramMap.get("id")
输出:空
然后我尝试了
this.route.snapshot.param
输出: {}
如何从这条路线获取 id?
解决方案
您可以访问当前路由的父级:
this.route.parent.snapshot.paramMap.get("id")
推荐阅读
- java - 基于用户组的文件存储可变路径
- chart.js - ChartJs - 以指定/固定间隔设置 x 轴刻度
- ios - 如何在 Swift 中自定义安全文本字段点
- python - 用美丽的汤刮 SERP
- mysql - 使用序列号字段将记录从 mysql 复制到 pgsql
- c# - 在 EF Core 中为所有实体设置字符串枚举转换器的通用方法
- python - Dash Python 中的 Plotly 未更新
- image - 图像作为 Google 表格中的单元格注释,在鼠标悬停/悬停时显示
- reactjs - 尝试输入反应应用程序路由时出现 404
- airflow - 在重建/更新 Google Cloud Composer 时减少延迟?