【发布时间】:2017-08-26 17:06:13
【问题描述】:
我是 Angular 2 的新手。我想在 app.component.ts 中使用 setTimeout()。我尝试引用许多其他帖子,但对我没有任何帮助。
下面是我尝试做的代码。
app.component.ts
catchError() {
if (navigator.onLine) {
console.log("connected");
this.displayNetworkError = false;
} else {
console.log("Disconnected");
this.displayNetworkError = true;
}
};
internetConnection() {
setTimeout(this.catchError(), 2000);
};
请帮我举几个例子。
【问题讨论】:
-
setTimeout(() => this.catchError(), 2000);你传递的是 callable 的东西,而不是 callable 的东西。
标签: angular typescript settimeout