user image

Published in : 2022-03-02

How to reload Angular component without refreshing page?


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 Date : 2022-03-06

Best answers


Best answers


You can do it by tricking the router event, and tell them that - you didn't visit the page. => { 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.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Adding country flags is really struggling thing?
Publish date: 2022-02-25 | Comments: 6

Tag: Angular

Static code analysis tools integration with latest Angular version
Publish date: 2022-02-25 | Comments: 1

Tag: Angular

Angular - PrimeNG charts adding colors for each legends dynamically
Publish date: 2022-02-27 | Comments: 1

Tag: Angular

How to bind Weekends off to my kendo calendar in Angular?
Publish date: 2022-03-11 | Comments: 2

Tag: Angular

Rename key inside Object {}
Publish date: 2022-03-05 | Comments: 2

Tag: Angular