0

I went over this stack overflow discussion. It clearly explains why we need the data attribute before the Angular directive. I also understand we can use the _ prefix instead of data, e.g.

<span _ng-bind="qty"></span> 

But I have two questions:

1) How does AngularJS know to use data or _? In other words, how does the Angular compiler understand this? Are these keywords built in Angular to support the HTML5 specifications?

EDIT:: I got answer for this from the official [Angular JS documentation][2. It is a process called Normalization, whereby it removes the extra word like "data" or "x" or "_" and converts the attribute to an Angular directive.

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). The normalization process is as follows:

  1. Strip x- and data- from the front of the element/attributes.
  2. Convert the :, -, or _-delimited name to camelCase

2) Suppose, if I already have a huge codebase not following the HTML5 specification, but rather just following the AngularJS directives. Then, is there any tool outside to convert AngularJS directives into HTML5 standards?

Please help me with this second question.

Community
  • 1
  • 1
user3278897
  • 984
  • 10
  • 23
  • A lot of libraries you gonna use like. angular-bootstrap uses ng-if, ng-style, etc. without any prefixes. Why you should use it then? – Petr Averyanov Jan 07 '16 at 01:22
  • For our existing project which is developed in Angular JS using the native Angular directives, i want to convert into HTML5 compliment. Manually doing this, is lot of work. So I am curious is their any tool, i searched and still i am searching. – user3278897 Jan 07 '16 at 01:34

0 Answers0