Angularjs two way data binding tutorial

As we discussed in earlier tutorials that ng-model directive is used to define the model or variable for a HTML element to be used in AngularJS i.e. it binds the state of HTML element with model value. If the value HTML element changes, AngularJS automatically change the model value and vice-versa.

Angularjs two way data binding diagram:

two-waybinding tutorialspointexamples

Example Explanation:

First include the AngularJS library in the application. The ng-app directive initializes the application. The ng-model directive binds the state of the input text to the name variable. When we enter a value in name input box, the corresponding value will automatically updated in next line and vice-versa.


<!DOCTYPE html>
 <script src=
   <div ng-app="">
    <p>Name: <input type="text" ng-model="name"></p>
     <h1>Hello {{name}}</h1>

Try it:

JS Bin on