Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refreshing a component in Angular 6

Tags:

angular

I am designing a dashboard based on angular 6. My dashboard has several different components arranged together. I want to refresh a component after every 5 minutes.

I have tried windows.location.reload() and location.reload() however it is refreshing the entire page and not just one component , i.e. to be specefic all my components are getting refreshed. So, please help and thanks in advance.

like image 665
Ashutosh Kumar Avatar asked Oct 17 '22 09:10

Ashutosh Kumar


1 Answers

Try this out

constructor(private ref: ChangeDetectorRef) {    
setInterval(() => {
  this.ref.detectChanges();
 }, 5000);
}
like image 166
chethu Avatar answered Nov 03 '22 17:11

chethu