Created
August 2, 2016 13:03
-
-
Save bhashkarsharma/a8425cf8050237ea78d0a715d95d360e to your computer and use it in GitHub Desktop.
Count the number of angular watchers
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 elements = document.getElementsByClassName('ng-scope'); | |
var watches = []; | |
var visited_ids = {}; | |
for (var i=0; i < elements.length; i++) { | |
var scope = angular.element(elements[i]).scope(); | |
if (scope.$id in visited_ids) | |
continue; | |
visited_ids[scope.$id] = true; | |
watches.push.apply(watches, scope.$$watchers); | |
} | |
return watches.length; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment