Is it possible to use the W3C validator for websites built in Angular.JS?

Asked

Viewed 44 times

1

I have a project, which was done in Angular.JS. When launching the project in W3C validator i get several mistakes that I wouldn’t have to deal with.

For example:
Attribute Errors: ng-controller | ng-cloak | ng-model | ng-click | ng-if | ng-repeat Error: Attribute not allowed on element.

Bad Value: Usually in href’s, or src’s filled from an angular variable {{minhaVariacel}}

Is there any possibility to treat so I can validate and get the W3C seal of a site with Angular.JS?

1 answer

1


According to the link from Angular Guide Normalization

Normalization makes:

  1. Remove x- and data- front of elements and attributes.
  2. Converts the :, -, or _ delimited to camelCase.

So to validate just add data- in front of the attributes, because the attributes with prefix data- are valid in HTML5.

Then the very Angularjs will "normalize" to work as if there were no data-, being like this:

  • data-ng-controller=""
  • data-ng-cloak=""
  • data-ng-model=""
  • data-ng-click=""
  • data-ng-if=""
  • data-ng-repeat=""

And for the src= and href= add data-ng- in the prefix, thus:

  • data-ng-src=""
  • data-ng-href=""

Ready, your site must validate.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.