Angular-bind-2

 

In this example, angular.bind call function multiply and pass the two value for 5 and 10 and return the output of multiply function. See the 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"> angular.bind result = {{Mul}} </div> </body> </html> <script> var app = angular.module("app", []); app.controller('bindController', ['$scope', function ($scope) { function multiply(a, b) { return a * b; } var mulData = angular.bind(this, multiply, 10); $scope.Mul = mulData(5); }]); </script>
Output