شمارش تعداد binding ها در Angularjs
پنجشنبه, ۱۶ بهمن ۱۳۹۳، ۰۸:۴۶ ق.ظ
function getScopeList(rs) {
var scopeList = [];
function traverseScope(s) {
scopeList.push(s);
if (s.$$nextSibling) {
traverseScope(s.$$nextSibling);
}
if (s.$$childHead) {
traverseScope(s.$$childHead);
}
}
traverseScope(rs);
return scopeList;
}
scopes = getScopeList(angular.element(document.querySelectorAll("[ng-app]")).scope());
total = _.uniq(_.flatten(scopes.map(function(s) { return s.$$watchers; }))).length;
لینک
۹۳/۱۱/۱۶