Wednesday, September 2, 2015

Angular two way data binding

                       Two way binding in Angular

Today i would show you a simple example of two way binding in Angular.
  • Like Knockout we do not need any observable. 
  • Less amount of code
  • When view changes model changes. When model changes view changes. This is known as two way binding

<!DOCTYPE html>
<html ng-app="myApp">
    <script src=""></script>
    <link rel="stylesheet" href="">
 <meta charset="utf-8" />
<body >
<div class="container" >
    <div class="row">
        <div ng-controller="Details">
            <div class="col-md-12" style="padding:20px;">
                <h2> Two way data binding</h2>
                FirstName :
                <input id="firstName" type="text" ng-model="FirstName" />
            <div class="col-md-12">
                    <b>My Name is :</b> {{FirstName}}  <br />
        //declare a module
        var myAppModule = angular.module('myApp', []);
        myAppModule.controller('Details', function ($scope) {
            $scope.FirstName = "Prathap";


No comments:

Post a Comment