- ng-app −> This directive characterizes and interfaces an AngularJS application to HTML.
- ng-model −> The values of AngularJS application data can be binded to HTML input controls by this directive.
- ng-bind −> Binding of the AngularJS application data to HTML tags is done by this directive.
In order to create AngularJS application, Notepad++ or any favorite tool and a browser is necessary and follow the steps given below:
Step 1 − Load the framework by using
<script>
tag as it is a pure JavaScript framework.
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
</script>
Step 2 − Using
ng-app
directive, one can define the AngularJS application .
<div ng-app = " ">
...
</div>
Step 3 − Define a model name using
ng-model
directive.
<p>Enter a Name: <input type = "text" ng-model = "name"></p>
Step 4 − Use
ng-bind
directive to bind the value of above defined model.
<p>Hello <span ng-bind = "name"></span>!</p>
Program Description:
[html]
<div ng-app="">
<p>Name: <input type="text" ng-model="name"></p>
<p>Welcome to <span ng-bind="name"></span></p>
</div>
[/html]