AngularJS ng-app Directive


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

<body ng-app="">

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

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.


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

Supported by all HTML elements.

Parameter Values

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


Load a module to keep running in the application

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

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