I want to execute some function on every $digest
cycle.
The documentation for $scope
reads:
If you want to be notified whenever $digest is called, you can register a watchExpression function with no listener. (Since watchExpression can execute multiple times per $digest cycle when a change is detected, be prepared for multiple calls to your listener.)
So does that mean it can be accomplished this way:
$rootScope.$watch(function () {
// Cron job
});
I'm not sure if every $digest
cycle hits the $rootScope
, or is it even emitted from $rootScope
. I only know there's only 1 $digest
loop and it occurs every time a $watch detects changes.