Just starting out with Angular 2 and trying to implement setTimeout()
in my app.component.ts
file. I've looked at various posts for guidance but haven't been successful so far.
Below is the snippet of code I've been attempting:
app.component.ts
handleError() {
if (navigator.onLine) {
console.log("connected");
this.displayNetworkError = false;
} else {
console.log("Disconnected");
this.displayNetworkError = true;
}
};
checkInternetConnection() {
setTimeout(this.handleError(), 2000);
};
If anyone could provide some working examples, I would greatly appreciate it!