angularjs data-ng-model vs - What is the difference between ng-app and data-ng-app?
None in terms of the runtime behavior, those are just different styles of naming directives as described here: http://docs.angularjs.org/guide/directive
Directives have camel cased names such as ngBind. The directive can be invoked by translating the camel case name into snake case with these special characters :, -, or _. Optionally the directive can be prefixed with x-, or data- to make it HTML validator compliant. Here is a list of some of the possible directive names: ng:bind, ng-bind, ng_bind, x-ng-bind and data-ng-bind.
As you can see from reading this the data-
can be used to make your HTML pass HTML validator tests/
I have begun to learn about AngularJS and am confused about what the differences are between the ng-app
and data-ng-app
directives.
In modern browsers there is no difference, but in older IEs, they won't work unless you declare an XML namespace defining it.
There is also a validation difference in that ng-app
is not valid XHTML, and will cause your webpage to fail HTML validations. Angular allows you to prefix its directives with data-
or x-
to allow it to validate.
The basic difference between these two terms is that data-ng-app validates the HTML while the latter don't.Functionality remains the same. For more reference you can try w3Validator.