Skip to content

Instantly share code, notes, and snippets.

@marcojahn
Created September 1, 2015 12:18
Show Gist options
  • Save marcojahn/2994edae6546200fb9f0 to your computer and use it in GitHub Desktop.
Save marcojahn/2994edae6546200fb9f0 to your computer and use it in GitHub Desktop.
// load underscore from browser console
$.get('https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js');
// execute the following code
function getScopes(root) {
var scopes = [];
function traverse(scope) {
scopes.push(scope);
if (scope.$$nextSibling)
traverse(scope.$$nextSibling);
if (scope.$$childHead)
traverse(scope.$$childHead);
}
traverse(root);
return scopes;
}
var rootScope = angular.element(document.querySelectorAll("[ng-app]")).scope();
var scopes = getScopes(rootScope);
var watcherLists = scopes.map(function(s) { return s.$$watchers; });
_.uniq(_.flatten(watcherLists)).length;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment