Created
August 12, 2014 16:15
-
-
Save jonmaim/fe19a8077de115a8e1e6 to your computer and use it in GitHub Desktop.
Get number of Angular watchers in the page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var root = angular.element(document.getElementsByTagName('body')); | |
var watchers = 0; | |
var f = function (element) { | |
if (element.data().hasOwnProperty('$scope')) { | |
watchers += (element.data().$scope.$$watchers || []).length; | |
} | |
angular.forEach(element.children(), function (childElement) { | |
f(angular.element(childElement)); | |
}); | |
}; | |
f(root); | |
return watchers; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Paste this in the console!
More info: http://stackoverflow.com/a/23470578