AngularJS directives are what controls the rendering of the HTML inside an AngularJS application, it also lets you to extends HTML by adding the directives.
In angular js directives are represented by prefix ng-
Some of the mostly used directives are as follows:-
1- ng-app
This directive is used to initaialise your application
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="" ng-init="firstName='Ankit'">
<p>Name: <input type="text" ng-model="firstName"></p>
<p>You wrote: {{ firstName }}</p>
</div>
</body>
</html>
The ng-app directive also tells that it is the author of the AngularJS application.
2- ng-int
This directive intializes the data of the application
<div ng-app="" ng-init="firstName='Ankit'">
<p>Name: <input type="text" ng-model="firstName"></p>
<p>You wrote: {{ firstName }}</p>
</div>
As above you can see the firstName is initialized.
3- ng-model
This directives binds the value of HTML controls (input, select, textarea) to the application data.
<p>Name: <input type="text" ng-model="firstName"></p>
4- ng-repeat
This directive is used to repeat the HTML elements
<div ng-app="" ng-init="names=['Patrick','Akki','Chettri']">
<ul>
<li ng-repeat="n in names">
{{ n}}
</li>
</ul>
</div>
0 Comment(s)