Last active
January 14, 2021 06:58
-
-
Save osmancansiz/31c59317ddfae2b937849e9a7c495283 to your computer and use it in GitHub Desktop.
Angular Same Page Routing with Params (Force Reload/Refresh)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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