Skip to content

Instantly share code, notes, and snippets.

@beholderrk
Last active August 29, 2015 14:16
Show Gist options
  • Save beholderrk/931eca3fa2e2b4d4347b to your computer and use it in GitHub Desktop.
Save beholderrk/931eca3fa2e2b4d4347b to your computer and use it in GitHub Desktop.
Show total count of angular watchers
function showWatchers() {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
angular.forEach(element.children(), function (childElement) {
f($(childElement));
});
};
f(root);
console.log(watchers.length);
};
showWatchers();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment