Why do some angular services use a dollar sign ("$") at the beginning?

4

I used some libraries written for AngularJS where Services were always written with a $ at first.

For example, in the Angular Material we have the service $mdDialog , and in Angular Bootstrap we have the $uibModal .

I already saw other libraries that did not use $ . As in the ngFileUpload module, we have the service Upload .

Until then I thought it was mandatory to use $ .

But I would like to know if this $ is some standardization or recommendation of Angular.

Is this meant to make a difference between Services and Factory, or something like this?

    
asked by anonymous 09.02.2017 / 14:13

1 answer

4

In some circumstances, the Angular ignores prefixed variables with the $ sign (dollar sign, or dollar sign ):

  • json filters do not generate output content;
  • When using the {{}} directive, Angular will not show properties started by $, only public properties;
  • Additionally, watch() does not fire for properties beginning with $ - these will be ignored when the viewer is being initialized;
  • Angular.equals() ignores keys prefixed with $ .

Font

    
09.02.2017 / 14:50