Is there any difference between $setTimeout in angular and native setTimeout?
世界只因有你2017-05-15 16:51:55
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 the false
,则不会使用 $apply
来包装 function 调用,也就是说不会更新当前作用域内的数据绑定。默认是 true
functiontrue
. Finally, these things are actually in the document...🎜