WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-app Directive


Example

Let the body component turn into the root component for the AngularJS application:

<body ng-app="">

<p>My first articulation: {{ 5 + 5 }}</p>

</body>
Try it yourself »

Definition and Usage

The ng-app order discloses to AngularJS this is the root component of the AngularJS application.

All AngularJS applications must have a root element.

You can just have one ng-app order in your HTML record. On the off chance that more than one ng-app order shows up, the principal appearance will be used.


Syntax

<element ng-app="modulename">
...
  content inside the ng-application root component can contain AngularJS code
...
</element>

Supported by all HTML elements.


Parameter Values

Value Description
modulename Optional. Determines the name of a module to stack with the application

Example

Load a module to keep running in the application

<div ng-app="myApp" ng-controller="myCtrl">
    {{ firstName + " " + lastName }}
</div>

<script>
var application = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
    $scope.firstName = "John";
    $scope.lastName = "Doe";
});
</script>
Try it yourself »