角JS命名约定($,驼峰和PascalCase) [英] Angular JS naming conventions ($, camelCase and PascalCase)
问题描述
什么是AngularJS为prefixing提供商$公约?
我应该preFIX在我自己的code所有定制服务?
What is the convention in AngularJS for prefixing providers with $? Should I prefix all custom services in my own code?
貌似附带有角prefixed服务的所有事情,例如 $ HTTP
。控制器,然而,在大多数的文章与 $
pfixed $ P $。
此外,所有的角code附带了驼峰
命名服务,但是我也看到 PascalCase
在许多网上博客。哪一个是约定?
Looks like all things that come with angular have prefixed services, e.g. $http
. Controllers, however, are not prefixed with $
in most articles.
Also, all angular code comes with services named in camelCase
, however I've also seen PascalCase
in many blogs online. Which one is the convention?
推荐答案
该文档说明此约定为内部服务,也说明你不应该做它自己的服务,以减少命名冲突。
The docs state this convention for internal services, but also state you should not do it for your own services to reduce naming collisions.
<一个href=\"http://docs.angularjs.org/guide/concepts#angular_namespace\">http://docs.angularjs.org/guide/concepts#angular_namespace
此外,关于驼峰,文档说使用驼峰。
Also, regarding camelCase, the docs say to use camelCase.
角使用名称与破折号属性名称和驼峰的
相应的指令名称
Angular uses name-with-dashes for attribute names and camelCase for the corresponding directive name
http://docs.angularjs.org/tutorial/step_00
这篇关于角JS命名约定($,驼峰和PascalCase)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!