At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.
<input>
element matches thengModel
directive<input ng-model="foo">
<input>
element matchesngModel
<input data-ng-model="foo">
<person>
element matches theperson
directive<person>{{name}}</person>
- Strip
x-
anddata-
from the front of the element/attributes. - Convert the
:
,-
, or_
-delimited name to camelCase.
- E: element names
- A: attributes
- C: class names
- M: comments