【发布时间】:2020-03-09 14:19:06
【问题描述】:
我想在 10000 秒内停止一个函数,但这不适用于 angular:
setTimeout(() => {
this
.ngZone
.run(() => {
if (device.name.includes('DeviceName')) {
this.connectToDevice(device)
}
});
}, 10000, console.log('not found'));
这会在 10000 秒后启动该功能,但我需要在 10000 秒后停止该功能并显示一条消息..
【问题讨论】:
-
this.connectToDevice是什么?在任何特定时刻你会如何阻止它? -
clearTimeout(yourSetTimeoutVariable)
标签: angular