我想基于同一页面中启用的视图附加浏览器网址。
默认网址:http://localhost:4200/xxx/disciplines
点击表格行后,它将更新为网址:http://localhost:4200/xxx/disciplines?disciplineId=1100
onRowClicked(event: any) {
this.isRowSelected = true;
this.selectedId = event.data.id; //event.id;
this.selectedItem = event;
console.log(this.selectedItem);
this.dataService.set(event);
this.router.navigate([], { queryParams: { disciplineId: this.selectedId } });
}
如果不使用this.router.navigate([], { queryParams: { disciplineId: this.selectedId } });
如何在单击某些按钮时附加http://localhost:4200/xxx/disciplines?disciplineId=1100&disciplineView=create
之类的新值。
如果我使用此this.router.navigate([], { queryParams: { disciplineView: view } });
网址已更改为
http://localhost:4200/xxx/disciplines?disciplineView=create
代替
http://localhost:4200/xxx/disciplines?disciplineId=1100&disciplineView=create
请专家提供建议吗?
答案 0 :(得分:0)
您应该使用queryParamsHandling: "merge"
。像这样:this.router.navigate([], { queryParams: { disciplineView: view }, queryParamsHandling: "merge" });
因此,这会将您的新参数合并到现有的已激活路线中。