I use ng-bind. But I have seen other developers using ngBind. Are they the same or is there any difference between them?

1 Answers

The real names of the directives are in camel case, for example, ngBind, ngModel, ngApp, ngInit, etc. In your code, you name them using the underscore, hyphen, or colon characters as word delimiters. For example, you can use any of the following naming variants of ng-bind in your code: ng-bind, ng:bind, ng_bind.

Optionally a name can be prefixed with data- or x- They are also valid names: data-ng-bind, x-ng-bind, x-ng:bind, x:ng:bind.

Angular normalizes an element/attribute name to check whether it matches a directive name. In the first step of the normalization process, Angular first strips the optional x- and data- from the front of the name. Then it converts the underscore, hyphen, or colon delimited name to camel case.

Prefixing a name with data- makes it HTML validator compliant.