Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavarePart 6.1-ngApp Directives
#1
ng-app Directives


-All AngularJS application must have a root element.
-Only one ng-app directive per html documents used.
-If more than one ng-app defined in html document then first appearance will be used.


Syntax:
Code:
<html ng-app="module-name">


module-name- -is optional or you can use specific application name defined in initialization of angualr js name here
var app=angular.module("myApp",[]);//now here myApp is the modulename for ng-app directive.
Scope of ng-app till the </html> tag.

Example:
Code:
<html ng-app="myApp">


Full Example of ng-app

Code:
<html ng-app="myApp"> //ng-app initialization name is that we defined in app name
<head>
<title>mvc</title>
<script src="../angular.min.js"></script>//give the path of angularJS File
<script type="text/javascript">
var app=angular.module("myApp",[]);
app.controller("myController",function($scope){
$scope.person={
'name':'ravi',
'mobile':'123456789'
}
});
</script>
</head>
<body>
<p>Show Model data in View through Controller</p>
<div ng-controller="myController">
Name:{{person.name}}
<br>
Mobileno:{{person.mobile}}
</div>
</body>
</html>


OUTPUT:
[Image: MjNFJt0.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)