user6680
user6680

Reputation: 139

Hiding only part of URL - Angular

I know I can do this

this.router.navigate(["/user-reviews"], username, userId, {skipLocationChange: true})

and the url won't change if I'm coming from

http://localhost:4200/main

and using skipLocationChange, but what I want it to say is http://localhost:4200/user-reviews/bob

How do I do it so that it only hides the userId parameter, but not the username and still retains the new path user-reviews instead of main? Is this possible? I appreciate any help!

Upvotes: 0

Views: 604

Answers (1)

JSmith
JSmith

Reputation: 4808

based on this post

you could easily do something like

ngOnInit()
{    
  this.location.replaceState("/user-reviews/something");
}

using location after navigate inside your component should do the trick.

Upvotes: 1

Related Questions