AngularJS | ng-app Directive
The ng-app Directive in AngularJS is used to define the root element of an AngularJS application. This directive automatically initializes the AngularJS application on page load. It can be used to load various modules in AngularJS Application.
Syntax:
<element ng-app=""> Contents... </element>
Example 1: This example uses ng-app Directive to define a default AngularJS application.
<html> <head> <title>AngularJS ng-app Directive</title> <script src= </script> </head> <body style="text-align:center"> <h2 style = "color:green">ng-app directive</h2> <div ng-app="" ng-init="name='GeeksforGeeks'"> <p>{{ name }} is the portal for geeks.</p> </div> </body> </html> |
Output:

Example 2: This example uses ng-app Directive to define a default AngularJS application.
<html> <head> <title>AngularJS ng-app Directive</title> <script src= </script> </head> <body ng-app="" style="text-align: center"> <h1 style="color:green">GeeksforGeeks</h1> <h2>ng-app Directive</h2> <div> <p>Name: <input type="text" ng-model="name"></p> <p>You entered: <span ng-bind="name"></span></p> </div> </body> </html> |
Output:

Recommended Posts:
- AngularJS | ng-cut Directive
- AngularJS | ng-value Directive
- AngularJS | ng-if Directive
- AngularJS | ng-src Directive
- AngularJS | ng-csp Directive
- AngularJS | Directive
- AngularJS | ng-jq Directive
- AngularJS | ng-srcset Directive
- AngularJS | ng-readonly Directive
- AngularJS | ng-paste Directive
- AngularJS | ng-required Directive
- AngularJS | input Directive
- AngularJS | ng-selected Directive
- AngularJS | ng-options Directive
- AngularJS | ng-bind Directive
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



