Last Updated: February 25, 2016
·
2.78K
· rickhuizinga

$scope.$evalAsync() vs. $timeout() In AngularJS

$scope.$evalAsync() vs. $timeout() In AngularJS

Sometimes, in an AngularJS application, you have to explicitly tell AngularJS when to initiate it's $digest() lifecycle (for dirty-data checking). This requirement is typically contained within a Directive; but, it may also be in an asynchronous Service. Most of the time, this can be easily accomplished with the $scope.$apply() method. However, some of the time, you have to defer the $apply() invocation because it may or may not conflict with an already-running $digest phase. In those cases, you can use the $timeout() service; but, I'm starting to think that the $scope.$evalAsync() method is a better option...