Skip to content

Instantly share code, notes, and snippets.

@aegiz
Last active November 7, 2015 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aegiz/b771b5bf5fc387ec3135 to your computer and use it in GitHub Desktop.
Save aegiz/b771b5bf5fc387ec3135 to your computer and use it in GitHub Desktop.
Count angular watchers (type this in your console)
javascript:(function () { var root = angular.element(document.getElementsByTagName('body')[0]); 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(angular.element(childElement)); }); }; f(root); alert(watchers.length);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment