Remove a parameter from queryParams angular 2 -


i navigate page in app query parameter. after parameter url want delete it, ideally have this:

let usertoken: string;     this.sub = this.router       .routerstate       .queryparams       .subscribe(params => {         usertoken = params['token'];         params['token'].remove();       }); 

but remove function doesn't exist. have alternative?

just in case people find thread (like did). have scenario receive jwt token in query string (/login?jwt=token). needed fetch token (and store etc), needed make sure got safely removed url. reloading login route (by using this.router.navigate(['login']) works in principe, however, user can use browser button, replaying token login.

i solved not using navigate di'ing 'location' service (from @angular/common). service has 'replacestate' method, removes token history wel url

 this.location.replacestate('login') 

hope helps someone.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -