AngularJS : Difference B/W ng-app vs. data-ng-app

AngularJS : Difference B/W ng-app vs. data-ng-app

Asked on October 16, 2018 in AngularJs.
Add Comment


  • 4 Answer(s)

    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.

    Answered on October 16, 2018.
    Add Comment

    In light of above proclamation underneath all are substantial orders
    1. ng-bind
    2. ng:bind
    3. ng_bind
    4. data-ng-bind
    5. x-ng-bind

    Answered on October 16, 2018.
    Add Comment

    ng-app directive:
    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

     

    Answered on December 18, 2018.
    Add Comment

    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

    1. ng-bind
    2. ng:bind
    3. ng_bind
    4. data-ng-bind
    5. x-ng-bind 

    Answered on January 18, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.