Search code examples
angularjsangularjs-scope

Why is a scope's $$watchers length not equal to the scope's $$watchersCount


What is the difference between a scope's $$watchers field and $$watchersCount? Why are they not always the same?

On the angularjs.org homepage, running angular.element('body').scope() in Chrome's developer tools, it's possible to see:

$$watchers: Array[3]
$$watchersCount: 80

What is the connection between these two fields?


Solution

  • $$watchers: Represent number of $$watchers array's length on current scope.

    Where as

    $$watchersCount: Number watchers present on current scope node & its descendants scope $$watchers array.length