Sometimes I see data-ng-controller
but more often ng-controller
The ng-controller
I already have used and this seems clear. But data-ng-controller
.. what is for?
What are the differences between them, and where to use what?
There is no difference except for validation and browser compatibility.
Angular js will not work in IE8 unless data is present
[Update]
Angularjs uses a normalization process for directive name / attributes matching.
From the angularjs docu at http://docs.angularjs.org/guide/directive.
Section Matching Directives:
The normalization process is as follows:
Strip x- and data- from the front of the element/attributes. Convert the :, -, or _-delimited name to camelCase.
There's no difference between the two, except that prefixing with data-
will allow the HTML to pass validation.
You may also see x-ng-controller. Both data- and x- are html5 custom attribute naming compliant.