Angularjs Ng-app Instruction
Angularjs instance
Let the body element be called the root element of the ANGULARJS application:
<! DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<script src = "http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"> </ script>
</ head>
<body ng-app = "">
<p> My first expression: {{5 + 5}} </ p>
</ body>
</ html>
Run Result:
My first expression: 10
Definitions and usage
The ng-app instruction is used to tell the ANGULARJS application that the current element is the root element.
All ANGULARJS applications must have a root element.
Only one ng-app instruction is allowed in an HTML document, and if there are multiple Ng-app directives, only the first one will be used.
Grammar
<element ng-app= "ModuleName" > ...
The content on the Ng-app root element can contain Angularjs code
...
</element>
All HTML elements support this directive.
Parameter values
value |
Description |
ModuleName |
Optional. Specifies the name of the load application module. |
Angularjs instance
Executing modules in the application
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
{{ firstName + " " + lastName }}
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
</body>
</html>
Operation Effect:
John Doe
Above is the Angularjs Ng-app instructions of the data collation, follow-up continue to add.