javascript - why do angular docs advice not to use public and private scope variables -


i'm using $$ & $ variables location service, stumbled upon piece of documentation. says not use them not provide reason. please enlighten me! https://code.angularjs.org/1.3.15/docs/api

angular prefixes $ , $$: prevent accidental name collisions code, angular prefixes names of public objects $ , names of private objects $$. please not use $ or $$ prefix in code.

using angular's $/$$-prefixed built-ins okay.

angular asking not create own scope variables, services , using prefixes reserved angular built-ins, avoid naming conflicts.

this recommended practice future-proof code. let's say, if create $foo service today , future version of angular adds $foo built-in, there naming conflict.

following recommendation, don't prefix code $/$$ , not conflict possible future angular built-in additions prefixed $/$$.

as byproduct, eases reading code, can more distinguish between built-in components , custom ones.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -