I am working on angular application where I want to update router url on some condition. below is the sample code:-
console.log(this.router.url) // it prints '/users'
this.location.replaceState('/users/1') // it updates the url bar with new url
console.log(this.router.url) //it prints same again '/user'
is there any way i can change the current route url without refreshing or reloading the page.
you probably should navigate to new route
In Angular (as SPA) it won't refresh or reload page but instantiate component for new route. If you want display user information in only one
divin the page without refreshing the rest (i.e. list of users), you can make use ofrouter-outlet.You can learn more here