Saturday, 5 October 2013

Two Way Binding-Lesson 2

Simple Example of Two Way bindings in Angular


Copy below code and paste it in a html and run it.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ng-app>
<head >
    <title></title>
     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <input type="text" ng-model="FooModel" placeholder="Enter Name" />

    <p>{{FooModel}}</p>
   <p>Note when you type something in text box, at the same time</p>
   <p>text updated in  paragraph i:e You are updating text box view in return it is updating</p>
  <p>FooModel. This FooModel is also associated with paragraph so it will automatically upadated.</p>
</body>
</html>

Hope this will help you to understand some basic about Angular Two Way bindings.
Use below url to test it.
http://plnkr.co/edit/6SxUIoYqbGChz3vS8WnQ



No comments:

Post a Comment