Monday, October 19, 2015

Angular two way binding


Two way data binding:  When the view changes model changes and when the model changes view                                        changes
Note: In angular we do not need observable as we need in Knockout
<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