One thing you can do with $rootScope.$watchis to give it a function without a "listener" (call it only one function that returns nothing). This effectively allows you to receive notifications through your provided feature when a digest occurs.
$rootScope.$watch(function() {
});
During the loop, this listener will be called twice, but I can’t say if I start or end without hacking. So I can just use the flag to help me keep track of the state we are in, and when we move from digestion to a fuzzy digest, we can clear our cache. In this example, I just create a service that creates a cache with $cacheFactoryand returns it, but monitors this state and clears it at the right time.
. , - . , watch . , , , , .
, $rootScope, $$postDigest, , , . , , $$postDigest, . , , API. .