AngularJs ng-app


AngularJs ng-app directive : AngularJs ng-app directive is used to define the root of the application. It is used to initialize the application automatically when the page loads


Syntax : AngularJs ng-app

<div ng-app = ''>

</div>

Note you can give your ng-app name .

Example

<div ng-app = 'MyApp'>

</div>

Let us understand with simple example

Example 1

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
</head>

<body>
<div ng-app="" ng-init= "name = 'Tani'">
    <p>Name : <input type='text' ng-model= 'name'></p>
    <p> {{name}}</p>

</div>
</body>
</html>

Try it »


Advertisements

Add Comment

📖 Read More