We will discuss directives, filters, Modules, Routes etc with examples in our upcoming Tutorial series.
To build angular applications you only need one script file and that is angular.js.
To get the script file visit https://angularjs.org. From here
1. You can download the angular script file
To get started with angular
1. Add a reference to the angular script
2. Include ng-app attribute
What is ng-app
In angular, ng-app is called a directive. There are many directives in angular.
You can find the complete list of directives on https://angularjs.org.
The ng prefix in the directive stands for angular.
The ng-app directive is a starting point of AngularJS Application.
Angular framework will first check for ng-app directive in an HTML page after the entire page is loaded.
If ng-app directive is found, angular bootstraps itself and starts to manage the section of the page that has the ng-app directive.
So the obvious next question is, where to place the ng-app directive on the page
It should be placed at the root of the HTML document,
that is at the <html> tag level or at the <body> tag level,
so that angular can control the entire page.
However, there is nothing stopping you from placing it on any other HTML element with in the page. When you do this only that element and it's children are managed by angular.
Double curly braces are called binding expressions in angular.
Example : In the example below, the ng-app directive is placed at the <html> tag level.
So the binding expressions in both the div elements are evaluated and displayed as expected.
output
To build angular applications you only need one script file and that is angular.js.
To get the script file visit https://angularjs.org. From here
1. You can download the angular script file
To get started with angular
1. Add a reference to the angular script
2. Include ng-app attribute
What is ng-app
In angular, ng-app is called a directive. There are many directives in angular.
You can find the complete list of directives on https://angularjs.org.
The ng prefix in the directive stands for angular.
The ng-app directive is a starting point of AngularJS Application.
Angular framework will first check for ng-app directive in an HTML page after the entire page is loaded.
If ng-app directive is found, angular bootstraps itself and starts to manage the section of the page that has the ng-app directive.
So the obvious next question is, where to place the ng-app directive on the page
It should be placed at the root of the HTML document,
that is at the <html> tag level or at the <body> tag level,
so that angular can control the entire page.
However, there is nothing stopping you from placing it on any other HTML element with in the page. When you do this only that element and it's children are managed by angular.
Double curly braces are called binding expressions in angular.
Example : In the example below, the ng-app directive is placed at the <html> tag level.
So the binding expressions in both the div elements are evaluated and displayed as expected.
<!DOCTYPE html>
<html>
<head>
<title> Ng-App Example </title>
<script src="../Scripts/angular.js"></script>
<meta charset="utf-8" />
</head>
<body>
<div>
<span>Angualr Js is work on ng-App section only </span>
</div>
<div ng-app>
10+20 ={{10+20}}
</div>
<div>
10+20={{10+20}}
</div>
</body>
</html>
output
Angualr Js is work on ng-App section only
10+20 =30
10+20={{10+20}}
1 comments:
commentsThank you for writing this quality informational content. Your writing technique is impressive and enjoyable to read. If you want about top android app development bangalore.
Reply