Important Notice:

Built-in Directives(ng-app)

Built-in Directives(ng-app)

12 views 2 min read

Built-in Directives:-

ng-app Directive

ng-app AngularJS का एक built-in directive है।
इसका उपयोग AngularJS Application को शुरू (initialize) करने के लिए किया जाता है।

यह AngularJS को बताता है कि HTML page का कौन-सा भाग AngularJS Application है।

English

ng-app is a built-in directive of AngularJS.
It is used to start (initialize) an AngularJS application.

It tells AngularJS which part of the HTML page is an AngularJS application.

syntax:-

<html ng-app="myApp">

          OR

<div ng-app="myApp">

Example  (<html ng-app="myApp">):-

<!DOCTYPE html>
<html ng-app="">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body>
<p>अपना नाम लिखिए:</p>
<input type="text" ng-model="name">
<h1>नमस्ते {{name}}</h1>
</body>
</html>

Example:-(<div ng-app="myApp">)

<!DOCTYPE html>
<html>
<head>
           <title>ng-app Example</title>
            <!-- AngularJS Library -->
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp">
          <h1>Hello Students</h1>
         <p>Enter Your Name:</p>
         <input type="text" ng-model="name">
         <h2>Welcome {{name}}</h2>
 </div>
<script>
           // Create AngularJS Module
            var app = angular.module("myApp", []);
</script>
</body>
</html>

 

Related Notes