使用路由器或ActivatedRoute在Angular中更改URL,而无需重新加载2打开的组件

使用路由器或ActivatedRoute在Angular中更改URL,而无需重新加载2打开的组件,angular,Angular,我使用的slidenav是隐藏的,在我更改URL之前不会显示任何数据 首先,我打开“站点”客户端:http://localhost:4200/clients 然后我搜索一个客户 现在,当我打开一个客户端时,它会导航到http://localhost:4200/clients/:id 我的搜索结果刚刚刷新,因为组件已重新加载 一个函数调用所选客户机的所有数据,而slidenav面板正好随数据滑入 问题: 如何在不重新加载组件的情况下更改URL。我想保留客户端列表的搜索结果 我已经试过使用@angu

我使用的slidenav是隐藏的,在我更改URL之前不会显示任何数据

首先,我打开“站点”客户端:http://localhost:4200/clients 然后我搜索一个客户

现在,当我打开一个客户端时,它会导航到http://localhost:4200/clients/:id 我的搜索结果刚刚刷新,因为组件已重新加载

一个函数调用所选客户机的所有数据,而slidenav面板正好随数据滑入

问题:

如何在不重新加载组件的情况下更改URL。我想保留客户端列表的搜索结果

我已经试过使用@angular/common中的“location”,但无法获取“route.snapshot.params.id”

有什么想法吗

showClient(id: number): void {
if (this.hasClientId) {
  this.closeSlidenav();
  this.router.navigate(['/clients/' + id]); // here it reload the component
  this.currentClient = this.getClientById(this.route.snapshot.params.id);
  if (this.currentClient) {
    this.viewChildClientContracts.ngOnInit();
  }
  this.openSlidenav();
}
}