Follow by Email

AngularJS Data binding

 Different ways to perform data binding in Angular JS :                                                           
a) ng-bind - The ng-bind directive will notify AngularJS to update the content of an HTML element with the value provided in the application scope variable.
   Different types of bindings :
1) One way binding using ng-bind
Example : 
         Controller :

    
          var app = angular.module('store', []);
           app.controller('myStore', function($scope) {
              $scope.stname = "Van husen";
              $scope.staddress = "Germany";
          });
    
  view :
        
         <div ng-bind="stname">
</div>

       
2) Two way binding using ng-bind, it works in the form of model to view and view to model.
Example :
        View :

    
        <div ng-app="store" ng-controller="myStore">
Name: <input ng-model="stname" />
          <br />
<h1>
{{stname}}</h1>
</div>
<a href="https://www.blogger.com/null" ng-click="getvalue"></a>
    
    

       Controller :

    
        var app = angular.module('myApp', []);
           app.controller('myStore', function($scope) {
            $scope.stname = "Van husen";
            $scope.staddress = "Germany";
            $scope.getvalue = fucntion(){
              console.log($scope);
          }
        });