AngularJS | Custom Directives naming standards

AngularJS has a set of built-in Directive which has HTML attributes with the prefix ng-. Make sure your directive naming does not conflicts with HTML5 attributes like <article>, <aside> & <details> etc.

Use an unique prefix

If you use a Directive as an element, add a prefix to all elements to avoid naming conflicts with future HTML5 and possible integrations with other Libraries.

Use a unique prefix as a kind of namespace to avoid naming collision with HTML current/future elements.

A recommended and wide spread convention from the Angular community is to have two letters prefix names that identifies your Application.

Example

  1. ng- (from the core)
  2. ui- (from angular-ui)

You can make unique prefix for your Application. Example, If you are developing Hotel Booking System just make name prefix hb-.

shanidkv's picture