27

Is there any difference between ng-repeat or data-ng-repeat in Angularjs?

I believe there are other directives with data prefix as well.

Thanks

Nexus23
  • 6,195
  • 9
  • 50
  • 67

1 Answers1

46

They are aliases. Angular allows both in order to name a directive. The data-ng-repeat allows the HTML to be validated through validators that do not understand Angular.

The documentation is here with directives.

This is from the docs:

Angular normalizes an element's tag and attribute name to determine which elements match which directives. We typically refer to directives by their case-sensitive camelCase normalized name (e.g. ngModel). However, since HTML is case-insensitive, we refer to directives in the DOM by lower-case forms, typically using dash-delimited attributes on DOM elements (e.g. ng-model).

And all these are valid:

  <span ng-bind="name"></span> <br/>
  <span ng:bind="name"></span> <br/>
  <span ng_bind="name"></span> <br/>
  <span data-ng-bind="name"></span> <br/>
  <span x-ng-bind="name"></span> <br/>

AFAIK, you can use these naming conventions in any directive that Angular parses.

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132