I have this route :
www.test.com/evidention?procesId=12&esid=12
I want to remove only this esid. Any suggestion how can i do that?
In the component or service where you want this deletion you can do the following:
export class ComponentOrService
{
constructor(
protected readonly route: ActivatedRoute,
protected readonly router: Router
) { }
deleteQueryParameterFromCurrentRoute()
{
const params = { ...this.route.snapshot.queryParams };
delete params.esid;
this.router.navigate([], { queryParams: params });
}
}
PS: [] here means to stay on the same route and only change queryParams
In angular 7+ there is error with "no provider for activatedroutesnapshot"
insteated you can use from ActivatedRoute
in constructor use
private _ActivatedRoute: ActivatedRoute
and with this you can change url parameters
var snapshot = this._ActivatedRoute.snapshot;
const params = { ...snapshot.queryParams };
delete params.esid
this.router.navigate([], { queryParams: params });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With