AngularJS : Difference B/W ng-app vs. data-ng-app
Great inquiry. The distinction is basic – there is positively no contrast between the two aside from that specific HTML 5 validators will toss a mistake on a property like ng-application, however they don’t toss a blunder for anything prefixed with data- , like ng-application.
So to answer your inquiry, utilize information ng-application in the event that you might want approving your HTML to be somewhat less demanding.
ng-app directive is the beginning directive of angularJS. It is used to auto bootstrap angularJS application. We generally use this directive at root level like inside html tag or in body tag.
<body ng-app> </body>
Example code for data-app is:
<!DOCTYPE html> <html> <head> <title>Tech Altum :- AngularJS Tutorial</title> <meta charset="UTF-8"> <script src="angular.min.js"></script> </head> <body> </body> </html>
Angular allows you to prefix its directives with data- or x- to allow it to validate. You can use data-ng-, instead of ng-, if you want to make your page HTML valid. The basic difference between these two terms is that data-ng-app validates the HTML while the latter don’t.Functionality remains the same
Angular normalizes an element’s tag and attribute name to determine which elements match which directives. We typically refer to directives by their case-sensitive camelCase normalized name (e.g. ngModel). However, since HTML is case-insensitive, we refer to directives in the DOM by lower-case forms, typically using dash-delimited attributes on DOM elements (e.g. ng-model).
The normalization process is as follows:
Strip x- and data- from the front of the element/attributes. Convert the :, -, or _-delimited name to camelCase. Here are some equivalent examples of elements that match ngBind:
based on above statement below all are valid directives