In my last article I tried to Introduce you about Angular JS. You may checked it here Introduction to Angular JS.
Directives available in Angular JS..
1.ng-app - This directive starts an AngularJS Application.
Example:
<!DOCTYPE html>
<html>
<script
src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app=" ">
....
....
</div>
</body>
</html>
Example:
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="" ng-init="Name='Ashraf'">
<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="Name"></p>
<p>You wrote: {{ Name }}</p>
</div>
</body>
</html>
Example:
<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div data-ng-app="" data-ng-init="quantity=1;price=5">
<h2>Cost Calculator</h2>
Quantity: <input type="number" ng-model="quantity">
Price: <input type="number" ng-model="price">
<p><b>Total in dollar:</b> {{quantity * price}}</p>
</div>
</body>
</html>
4.ng-repeat - This directive repeats html elements for each item in a collection.
Example:
<!DOCTYPE html>
<html>
<script
src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="" ng-init="names=[
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]">
<p>Looping with objects:</p>
<ul>
<li ng-repeat="x in names">
{{ x.name + ', ' + x.country }}</li>
</ul>
</div>
</body>
</html>
No comments:
Post a Comment