Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

W3C validation with AngularJS directives

How do we go about doing W3C validation with an Angular application?

Since custom directives make for invalid HTML validation, we typically see lots of W3C validation errors. Are there any strategies for this?

like image 483
AndyB Avatar asked Jun 05 '13 21:06

AndyB


People also ask

What is used for validating AngularJS forms?

Form Validation AngularJS also holds information about whether they have been touched, or modified, or not. You can use standard HTML5 attributes to validate input, or you can make your own validation functions. Client-side validation cannot alone secure user input. Server side validation is also necessary.

What are the binding directives in AngularJS?

The ng-bind directive tells AngularJS to replace the content of an HTML element with the value of a given variable, or expression. If the value of the given variable, or expression, changes, the content of the specified HTML element will be changed as well.


1 Answers

Strict w3c validation allows any data-* attributes, and any class.

Directives can be applied to DOM elements with any of:

  1. <tag directive-name>
  2. <tag data-directive-name> (*)
  3. <tag x-directive-name>
  4. <tag directive_name>
  5. <tag x_directive_name>
  6. <tag data_directive_name>

At least the data- one is fully W3C compliant (provided you declare HTML5 doctype). So the following code validates (the attribute name, of course it fails for missing title, missing encoding etc):

<!DOCTYPE html> <html>  <body data-ng-app="MyApp">  </body> </html> 
like image 118
rewritten Avatar answered Oct 02 '22 06:10

rewritten