Skip to content

Instantly share code, notes, and snippets.

View smonusbonus's full-sized avatar

Simon Kreiser smonusbonus

View GitHub Profile
@smonusbonus
smonusbonus / get-angular-watchers.js
Last active January 23, 2018 11:01
Angular debug script for getting watchers of a certain directive or DOM element. Based on: https://gist.github.com/kentcdodds/31c90402750572107922
function getWatchers(root) {
root = angular.element(root || document.documentElement);
console.log('You selected this element:', root);
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));