JavaScript

JavaScript

Made by DeepSource

Specify consistent use of $scope.digest() or $scope.apply() JS-0552

Performance
Minor
angularjs

For the execution of the watchers, the $digest method will start from the scope in which we call the method. This will cause an performance improvement comparing to the $apply method, who start from the $rootScope.

Rule based on Angular 1.x

Bad Practice

// invalid
$scope.$digest(); // error: Instead of using the $digest() method, you should prefer $apply()

Recommended

// valid
$scope.$apply(function() {
    // ...
});