AngularJS and its use of Dollar Variables
It is just a naming convention from the below snippet http://docs.angularjs.org/tutorial/step_05
'$' Prefix Naming Convention
You can create your own services, and in fact we will do exactly that in step 11. As a naming convention, angular's built-in services, Scope methods and a few other angular APIs have a '$' prefix in front of the name. Don't use a '$' prefix when naming your services and models, in order to avoid any possible naming collisions.
http://docs.angularjs.org/guide/concepts#angular_namespace
Angular Namespace
To prevent accidental name collision, Angular prefixes names of objects which could potentially collide with $. Please do not use the $ prefix in your code as it may accidentally collide with Angular code.
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.<div ng-init="n = { visible: 'foo', $ignore: 'bar' };">{{ n }}</div>
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$
.