angular - 如何保存从用户那里获得的路由参数的值并将其保存以供其他组件使用?
问题描述
我有一个用户列表,我可以单击其中一个并检索特定的 id(codSoggetto),然后使用路由参数路由到具有该 id 的另一个组件。我想用于其他组件的那个 id 我该怎么做?如何保存或用于其他组件?
export class ListaUtentiComponent implements OnInit {
userList: Array<List>;
public itemcodSoggetto;
constructor(private _userService: UserService,
private route: ActivatedRoute,
private router: Router) {}
ngOnInit() {
this.getCafUserList();
let codSoggetto = this.route.snapshot.paramMap.get('codSoggetto');
this.itemcodSoggetto = codSoggetto;
}
getCafUserList(): void {
this._userService
.getCafUserList()
.subscribe(res => this.userList = res);
}
onSelect(item){
this.router.navigate(['/homeb', item.codSoggetto]);
}
}
解决方案
推荐阅读
- sql - 如何在 SQL 表中选择一个随机行并在那里插入一些东西?
- mysql - 如何停止插件在特定 wp 页面上发送查询
- c++ - 流输入运算符导致使用 clang 的分段错误,但适用于 gcc
- python - Python PyGame 图像(大金刚)不动
- c# - 在Delphi中加载C# DLL找不到依赖库DLL
- python-3.x - 将“色调”用于 Seaborn 视觉效果:如何在一张图中获取图例?
- angular - Angular 8 路由解析器在返回 EMPTY 时不会取消路由导航
- android - Android Studio 的默认 MapsActivity 代码不起作用
- javascript - 如何访问动态创建的锚标签jquery的数据属性
- reactjs - 如果 react-script 比 3.0.0 新,则会出现错误消息“'Office' is not defined no-undef”