Secondly, $timeout 是对 window.setTimeout is a one-layer package with basically the same functions and interfaces. The main differences are as follows:
The incoming function is packaged in try...catch 结构内,并且把抛出的异常委托给 $exceptionHandler for unified scheduling processing;
$timeout 返回的不是数字 ID,而是一个 promise 对象。这意味着你无法用 window.clearTimeout 取消它,而是要用 $timeout.cancel(returnedPromise) to cancel;
The third parameter passed in is a Boolean value. If false is passed in, $apply will not be used to wrap the false,则不会使用 $apply 来包装 function 调用,也就是说不会更新当前作用域内的数据绑定。默认是 truefunction
call, which means it will not Update data bindings within the current scope. The default is true.
Finally, these things are actually in the document...🎜
First of all, there is no
$setTimeout
,是$timeout
.Secondly,
$timeout
是对window.setTimeout
is a one-layer package with basically the same functions and interfaces. The main differences are as follows:try...catch
结构内,并且把抛出的异常委托给$exceptionHandler
for unified scheduling processing;$timeout
返回的不是数字 ID,而是一个 promise 对象。这意味着你无法用window.clearTimeout
取消它,而是要用$timeout.cancel(returnedPromise)
to cancel;false
is passed in,$apply
will not be used to wrap thefalse
,则不会使用$apply
来包装 function 调用,也就是说不会更新当前作用域内的数据绑定。默认是true
functiontrue
.