I have 3 different page on my angular (im using Angular 6), but im still confusing how to make all of my pages auto refresh/reload with interval time.
Is there any way to make function or etc ? relate to auto refresh/reload in each of page component.ts, component.html, or maybe in app-routing.module ?
Any suggestion or experience to make something like that ?
For example component.ts:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-example-page',
templateUrl: './example-page.component.html',
styleUrls: ['./example-page.component.less']
})
export class ExamplePageComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
Example
import { Observable, interval, Subscription } from 'rxjs';
export class YourComponent ... {
private updateSubscription: Subscription;
ngOnInit() {
this.updateSubscription = interval(1000).subscribe(
(val) => { this.updateStats()
}
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With