Question
Does anyone know if the reasoning behind the use of dollar methods and
variables in angularJS is to instruct angularJS to avoid checking those values
when a digestion is going on? So, if angular comes across $scope.$value
and
$scope.value
, then it will avoid checking the former since it's prefixed
with a dollar character in its variable name?
Answer
There are a few times Angular ignores variables prefixed with the dollar sign:
-
In Schumli's comment below, where json filters will not output them
-
When using the
{{ }}
directive, angular will not show nested$
variables. For example this only displays thevisible
property.{{ n }} -
Additionally when adding an explicit watcher on a scope object, changes to properties with a leading dollar sign of this object will not trigger the watcher. See this updated fiddle.
-
angular.equals()
ignores keys prefixed with$
.