Directives

Directives are what Angular uses to connect to the Document Object Model (DOM). This allows Angular to separate the concerns of what each part of the application should do. This means that a controller should never touch the DOM. A controller should only work through directives to change the DOM.

Normalization

When using directives, Angular must parse the DOM and figure out what directives apply to it. This is done by normalizing all the elements and tags. Normalization will remove any ";" "," " -", or" _". It will also remove x- and data- from the beginning of any attributes. For example, when looking for ngModel, all of the following will match:

  • x-ng:model
  • data-ng_model
  • ng-model
  • ng:model

Note

If you are concerned with HTML 5 validation, ...

Get Web Developer's Reference Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.