Tuesday, 18 April 2023

angualr reload same component

 common way:

https://stackoverflow.com/questions/40983055/how-to-reload-the-current-route-with-the-angular-2-router

        //this.router.routeReuseStrategy.shouldReuseRoute = () => false;

        //this.router.onSameUrlNavigation = 'reload';

        //this.router.navigate([this.router.url]);


However this casues the entire router config to be changed, as router is like a service and it is singleton, so everyother componet will reload .


To avoid, create a component that is under a differnt url

like my-redirect-component,

then in there, do this.router.navigate([this.router.url])

No comments:

Post a Comment