Skip to content

Instantly share code, notes, and snippets.

@alfrescian
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save alfrescian/8c8a0aecd599310782cd to your computer and use it in GitHub Desktop.

Select an option

Save alfrescian/8c8a0aecd599310782cd to your computer and use it in GitHub Desktop.
Angular $watch count
javascript: (function () { 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);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment