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

Asked

Viewed 291 times

4

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

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

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

Until then I thought it was mandatory to wear $.

But I wonder if that $ is some standardization or recommendation of Angular.

This is to make a difference between Services and Factory, or something like that?

  • 5

    'Cause it gets prettier.

  • Or would it be to use the same name for directive and service? Because using the $ the conflict would be broken, right?

  • 5

    To look like php.

  • 5

    To look like jQuery.

  • 3

    To look like Prototype.

  • You’re not worth a dollar...

Show 1 more comment

1 answer

4


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

  • Json filters do not generate output content;
  • When using the directive {{}} Angular will not show properties initiated by $, only public properties;
  • Moreover, watch() does not fire on properties that begin with $ - these will be ignored when the observer is being initialized;
  • Angular.equals() ignores keys prefixed with $.

Source.

  • Very important this information. So the $ is not only firula.

  • 1

    @Correct wallacemaxters, there is functionality behind the use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.