我想在我的网址中有一个固定的queryParameter,它反映了当前的应用程序实例。例如...&instance=xyz
到目前为止,这是我的一个组件:
ngAfterViewInit(){
let currentInstanceParam = this.router.routerState.root.queryParams['instance'];
if (!currentInstanceParam){
// always add current instance as parameter
this.router.navigate([this.router.url], {queryParams: {instance: this.loginService.getLoginData().currentDataSource}});
}
}
它有效 - 如果未设置参数,则会添加。
可是:
preserveQueryParams
)