我是新角度2.我想在app.component中使用setTimout。我嘗試了很多其他帖子,但沒有爲我工作。Angular 2:SetTimout
下面是我正在嘗試的代碼。請以示例幫助我。
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 *,而不是* *。 – jonrsharpe