angular-bind-3

 

angular.bind call the function isEqual and value of parameters a and b will passed from textbox. isEqual function return result according to condition. See code snippet:

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="bindController"> A <input type="number" ng-model="val1" ng-change="GetResult()" /> B <input type="number" ng-model="val2" ng-change="GetResult()" /><br /> {{result}} </div> </body> </html> <script> var app = angular.module("app", []); app.controller('bindController', ['$scope', function ($scope) { function isEqual(a, b) { if (a == b) { return "Values are equal." } else if (a >= b) { return "A is greater than B." } else if (a <= b) { return "A is lesser than B." } } $scope.GetResult = function () { var result = angular.bind(this, isEqual); $scope.result = result($scope.val1, $scope.val2); } }]); </script>
Output