angularbind – AngularJS Bind Function – Angular Binding Examples

angularbind – AngularJS Bind Function – Angular Binding Examples

here angular.bind Returns a function simple all the function which calls function fn syntax bound to self means this (self make the this for fn). we can provide optional args or param that are unbound(prebound) to the angularjs function. This feature support is also known as all the data partial web-application, as and other way to the distinguished from javascript function currying.angular.bind – AngularJS Bind Function – Angular Binding Examples

angular.bind Syntax(uses)

angular.bind(self, fn, [yourargs]);

Arguments for angular.bind

1.self – Context which fn would be evaluated in.
2.fn – Function or method to be bound.
3.yourargs – Optional arguments to be prebound (conditions) to the fn function call.

READ :  Angularjs push object into array first index - angularjs unshift Examples

AngularJS bind directive or function is used to HTML bind the current data or context to a functionangular.bind

Simple Data binding module in AngularJS is the all the data synchronization between the model level and the view.“AngularJS Bind Function”

HTML View using bind

 <p ng-bind="myfirstproject"></p> 

Angular.bind will all the bind to a function used to angular.bind which call another all the javascript function and arguments will multiple param also passed from addData

AngularJS Bind Function with http Request Example

$http.get('www.infinityknow.com/api/index.php/getdata').then(angular.bind(this, 
function(response) { 
	this.response = response; //simple use this (which is all the bound data context) 
});

Example

AngularJS Bind Function Example – 1

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>AngularJS Bind Function Example</title>
    <script src="angular.min.js"></script>
	<script>
    var infinityApp = angular.module("infinityApp", []);
    infinityApp.controller('liveCtrl', ['$scope', function ($scope) {
        $scope.first = 50;
        $scope.liveValue = function () {
            var addData = angular.bind(this, function (a, b) {
                return a + b;
            });
            $scope.Add = addData(10, $scope.first);
        }
    }]);
 
</script>
</head>
<body ng-app="infinityApp">
<h2>angularbind - AngularJS Bind Function</h2>
    <div ng-controller="liveCtrl">
	<p>Please Enter your Value</p>
        <input type="number" ng-model="first" ng-change="liveValue()" />
        Addition={{Add}}
    </div>
</body>
</html>

Example

READ :  AngularJS datagrid paging sorting filter using PHP and MySQL

AngularJS Bind Function – angular.bind() Example

<!DOCTYPE html>        
<html>        
<head> <!-- www.infinityknow.com -->        
<title>AngularJS $scope.bind() Example</title>        
<script src="angular.js"></script>   
 <script> 
  var app = angular.module('infinityknowApp', [])            
     app.controller('liveCtrl', ['$scope', function($scope) { 
       $scope.Name = "";
       $scope.respnose = "";
      var greet = function (greeting, punctuation) {
        $scope.respnose = greeting + ' ' + $scope.Name +''+ punctuation;
      };
       $scope.callliveBind = function () {
        var bound = angular.bind(this, greet, 'Welcome');
         bound('!!!!!');
      };
     }]);        
</script>        
</head>        
<body style="background-color:yellow;" ng-app="infinityknowApp">        
  <fieldset style="background-color:yellow;">          
    <legend>Simple AngulerJS $scope.bind() easy Example</legend>          
<div ng-controller="liveCtrl">        
<p style="font-family:Arial;color:pink;background:green;padding:4px;width:150px;">{{respnose}}</p>
  
     <input ng-model="Name">    
    <button ng-click="callliveBind()">Call Bind</button> 
      </fieldset>         
</body>        
</html> 

Add a Comment

Your email address will not be published. Required fields are marked *