📅  最后修改于: 2022-03-11 15:02:55.693000             🧑  作者: Mango
// Make sure to import and define the Angular Router and current Route in your constructor
constructor(
private router: Router,
private route: ActivatedRoute
) {}
...
...
...
// Take current queryParameters from the activated route snapshot
const urlParameters = Object.assign({}, this.route.snapshot.queryParams);
// Need to delete a parameter ?
delete urlParameters.parameterName;
// Need to add or updated a parameter ?
urlParameters.parameterName = newValue;
// Update the URL with the Angular Router with your new parameters
this.router.navigate([], { relativeTo: this.route, queryParams: urlParameters });