Shilpa
Published in : 2022-03-02
I am using Angular 10 and it is `single page application`, so I want to avoid refreshing the page using `window.location.reload()` or `location.reload()`.
What are the way/ways to achieve refreshing sub-component values without using typescript's programmatic reload() function?
You can do it by tricking the router event, and tell them that - you didn't visit the page.
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
// Tell the router that you didn't visited last link and so it wasn't previously loaded
this.router.navigated = false;
}
});
Hope it helps!
Source: Refresh Angular component without reloading or refreshing a page.
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now