Skip to content

Instantly share code, notes, and snippets.

@gustavohenke
Last active December 28, 2019 01:50
Show Gist options
  • Save gustavohenke/f7759ef1909a60276633 to your computer and use it in GitHub Desktop.
Save gustavohenke/f7759ef1909a60276633 to your computer and use it in GitHub Desktop.
Collect all Angular.js scopes
function collect( element ) {
var scope;
var watchers = [];
element = angular.element( element );
scope = element.data("$scope");
if ( scope ) {
watchers = scope.$$watchers || watchers;
}
angular.forEach( element.children(), function( child ) {
watchers = watchers.concat( collect( angular.element( child ) ) );
});
return watchers;
}
collect( document ).length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment