Skip to content

Instantly share code, notes, and snippets.

@osmancansiz
Last active January 14, 2021 06:58
Show Gist options
  • Save osmancansiz/31c59317ddfae2b937849e9a7c495283 to your computer and use it in GitHub Desktop.
Save osmancansiz/31c59317ddfae2b937849e9a7c495283 to your computer and use it in GitHub Desktop.
Angular Same Page Routing with Params (Force Reload/Refresh)
constructor(private router: Router){
// override the route reuse strategy
this.router.routeReuseStrategy.shouldReuseRoute = function(){
return false;
}
this.router.events.subscribe((evt) => {
if (evt instanceof NavigationEnd) {
// trick the Router into believing it's last link wasn't previously loaded
this.router.navigated = false;
// if you need to scroll back to top, here is the right place
window.scrollTo(0, 0);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment