Search code examples
htmlangularjsvalidation

validation of AngularJS direcrives


I read on W3C School that to make a valid HTML page I have to add data before each angular directive in HTML file (e.g.:

<p>The name is <span data-ng-bind="firstName"></span></p>

or

<div data-ng-app="" data-ng-init="firstName='John'">

Ok that's fine. I have two questions:

  1. Should this prefix be used only for ng- directives?
  2. Could this data- prefix create problems with Angular third-party libraries?

Solution

  • data- prefix can be used by any directive and the underlying directive name normalization process takes care of matching the directive attribute declaration with the directive implementation.

    More details about the normalization process is available in the directive user guide under section "Matching Directives".

    Hence adding data- prefix to to any directive does not affect any third party directives.