when $digest cycle is called?

前端 未结 3 1394
面向向阳花
面向向阳花 2020-12-01 10:43

I\'m very confused when a digest cycle is happening, is it called periodically based on a timer every 50ms (as it says here and implied here) or is it called after every eve

3条回答
  •  庸人自扰
    2020-12-01 11:20

    Any AngularJS scope variable when handled from outside (including ajax) needs a $apply().

    setTimeout is Javascript function So $apply is needed to update angularjs values.

    $timeout is a angularjs function which returns promise and takes care of the current scope and runs in the same digest cycle.

    So need not of $apply() function to update values.

提交回复
热议问题