Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9e63e65

Browse files
committed
Merge pull request #14 from vaneri/master
[angular-snippet]drop the watchers on the console as well as their number
2 parents e4b635a + 1f41b30 commit 9e63e65

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎ng-count-watchers.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
// taken from http://ng.malsup.com/#!/counting-watchers
22
(function countAngularWatchers(angular) {
33
var i, data, scope,
4-
count = 0,
5-
all = document.all,
6-
len = all.length,
7-
test = {};
4+
count = 0,
5+
all = document.all,
6+
len = all.length,
7+
test = {},
8+
watchers = [];
89

910
var mostWatchers = 0;
1011

1112
function countScopeWatchers(scope, element) {
1213
test[scope.$id] = true;
1314
var n = scope.$$watchers.length;
1415
count += n;
16+
if (n > 0){
17+
watchers.push.apply(watchers, scope.$$watchers);
18+
}
1519
if (n > mostWatchers) {
1620
console.log('most watchers', n);
1721
console.log(element);
1822
mostWatchers = n;
23+
1924
}
2025
}
2126

@@ -30,6 +35,6 @@
3035
}
3136
}
3237
}
33-
console.log('this page has',count,'angular watchers');
38+
console.log('this page has '+watchers.length+' angular watchers and the watchers are:',watchers);
3439
return count;
3540
}(window.angular));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /