Shilpa
2 Mar 2022
Angular
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?
Rakshit
6 Mar 2022
Best Answer
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.
© 2024 Copyrights reserved for web-brackets.com