Last active
December 28, 2019 01:50
-
-
Save gustavohenke/f7759ef1909a60276633 to your computer and use it in GitHub Desktop.
Collect all Angular.js scopes
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 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