AngularJs Directives Intro
AngularJs Directives : AngularJs Directives are extended html attributes used in angularJs.
AngularJs Directives
AngularJs Directives starts with ng- prefix.
There are following common directives in AngularJs
1. ng-app : Is used to initialize the application.
2. ng-init : Is used to initialize the application data.
3. ng-model : Is used to bind the value of HTML with the application data.
Let us understand with simple example
Example 1
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script> </head> <body> <div ng-app="" ng-init="myArr=['First Item','Second Item']" > <p><input type='text' name='firstItem' ng-model= 'myArr[0]'></p> <p><input type='text' name='secondItem' ng-model= 'myArr[1]'></p> <p> {{myArr[0] + " , " +myArr[1]}}</p> </div> </body> </html> |
Advertisements