I'm learning AngularJS and I found a simple code like this one:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
</head>
<body ng-app ng-init="name = 'World'">
<h1>Hello, {{name}}!</h1>
</body>
</html>
does not pass W3C validation test, mainly because there are non standard attributes (ng-app
, ng-init
).
The question is: should I care about W3C validation of my application? Should I abandon AngularJS?
You could use the data- html5 attribute which is standard and as far as I know works the same for Angular. Something like:
data-ng-app=""
data-ng-init="xxx"
Will work the same in Angular and are validated by W3C.
Look also at this: ng-app vs. data-ng-app, what is the difference?
Aside from that, from my experience working with standards is always better when your product will be delivered to a possible large crowd (so you'r building a website or a public webapp and so on) with different clients, versions etc. If you're building a SPA using angular and maybe phonegap to create a mobile app which will be installed on mobile devices as a native app, standard could not be that important, the important thing is that it will work on your target devices.