Skip to content

Instantly share code, notes, and snippets.

@Colorfulstan
Last active July 20, 2016 19:46
Show Gist options
  • Save Colorfulstan/8c15d536e461c50950aa7f4e13cd41e1 to your computer and use it in GitHub Desktop.
Save Colorfulstan/8c15d536e461c50950aa7f4e13cd41e1 to your computer and use it in GitHub Desktop.
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
angular.forEach(element.children(), function (childElement) {
f($(childElement));
});
};
f(root);
console.log(watchers.length);
})();
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
angular.forEach(element.children(), function (childElement) {
f(angular.element(childElement));
});
};
f(root);
console.log(watchers.length);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment