Angular 回调按钮时删除查询参数
Angular remove query param when call back button
我需要检查我的收入 URL 是否是特定的合成物然后打开模式并做一些事情。我使用以下代码执行此操作:
route.queryParams.subscribe(async params => {
if (!isNaN(params.rt)) {
console.log("URL Match");
this.show = true;
} else {
console.log("URL does not Match");
}
});
我的格式应该是这样的:
www.example.com?=123456
但我需要完整的模态过程,从url
中删除查询参数
要删除查询参数,您可以像下面那样做。
let url: string = this.router.url.substring(0, this.router.url.indexOf("?"));
this.router.navigateByUrl(url); // where this.router will be intialized in ex:// constructor(private router:Router) {}
这 link 可能会有所帮助。
我需要检查我的收入 URL 是否是特定的合成物然后打开模式并做一些事情。我使用以下代码执行此操作:
route.queryParams.subscribe(async params => {
if (!isNaN(params.rt)) {
console.log("URL Match");
this.show = true;
} else {
console.log("URL does not Match");
}
});
我的格式应该是这样的:
www.example.com?=123456
但我需要完整的模态过程,从url
中删除查询参数要删除查询参数,您可以像下面那样做。
let url: string = this.router.url.substring(0, this.router.url.indexOf("?"));
this.router.navigateByUrl(url); // where this.router will be intialized in ex:// constructor(private router:Router) {}
这 link 可能会有所帮助。