I've found myself knee-deep in a legacy AngularJS project lately. The codebase is quite intricate and expansive, making it difficult to showcase here. However, I've come across an issue where functions triggered during digest changes are firing hundreds of times per second indefinitely, even when the page remains dormant. This realization dawned on me as I monitored the console logs closely. For instance, if I integrate a function such as:
$rootScope.$watch(function (e) {
console.log('digest changed' );
});
and observe the console log output, 'digest changed' will flood the screen relentlessly. It's evident that this perpetual triggering of the digest cycle isn't ideal. Is there a method for pinpointing the root cause of this tumultuous cycle? I'd appreciate any guidance you can offer!