I have a problem. I'd like to reload website after 5 minutes and that is my question, how to reload website in Typescript/Angular application?
The location. reload() method reloads the current URL, like the Refresh button.
In your main app component file, under ngOnInit(), you could add a setTimeout method that reloads every 5 minutes like so:
ngOnInit() {
setTimeout(() => {
window.location.reload();
}, 300000); // Activate after 5 minutes.
}
Though I don't know your situation, I would highly advise against doing this. Most likely, whatever you are trying to accomplish, can probably be done in a better way than refreshing the page. That's just my opinion. For me as a User, i'd be really annoyed if i'm browsing a site and it just randomly refreshes.
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