Skip to content

Instantly share code, notes, and snippets.

@johnpapa
Created September 3, 2014 17:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpapa/77e327750960073bc07f to your computer and use it in GitHub Desktop.
Save johnpapa/77e327750960073bc07f to your computer and use it in GitHub Desktop.
watchers.js
(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);
var output = [];
console.log(watchers.length);
for(var x=0; x < watchers.length; x++) {
var w = watchers[x];
var data = {
last: w.last,
exp: w.exp,
evaluated: typeof w.exp === 'function'? w.exp() : w.exp
};
output.push(data);
}
console.table(output);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment