AngularJS

Angular Best Practice: Naming Conventions

Summary: UpperCamelCase for Controllers and constructor Services, lowerCamelCase everywhere else.

Controllers

The naming of the controller is done using the controller’s functionality (for example shopping cart, homepage, admin panel) and the substring Ctrl in the end. The controllers are named UpperCamelCase (HomePageCtrl, ShoppingCartCtrl, AdminPanelCtrl, etc.).

Directives

Name your directives with lowerCamelCase.

Filters

Name your filters with lowerCamelCase.

Services

Use camelCase to name your services.

  • UpperCamelCase (PascalCase) for naming your services, used as constructor functions
  • lowerCamelCase for all other services.

Note that Services always return singletons. Unless you create a special service to return a newed object each time it gets called–in this case, and only in this case should you use PascalCase naming.

Reference: angularjs-style-guide

Standard