angular.bind
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { function add(a, b) { return parseInt(a)+parseInt(b); } $scope.getResult = function () { var result = angular.bind(this, add); $scope.result = result($scope.input1, $scope.input2); } }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> Enter a number 1. <input type="text" name="addExample1" ng-model="input1"><br> Enter a number 2 <input type="text" name="addExample2" ng-keyup="getResult()" ng-model="input2"> <br>number 1 + number 2 = {{result}}<br> </div> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { function add(a, b) { return parseInt(a)+parseInt(b); } $scope.getResult = function () { var result = angular.bind(this, add); $scope.result = result($scope.input1, $scope.input2); } }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> Enter a number 1. <input type="text" name="addExample1" ng-model="input1"><br> Enter a number 2 <input type="text" name="addExample2" ng-keyup="getResult()" ng-model="input2"> <br>number 1 + number 2 = {{result}}<br> </div> </div> </body> </html>
Copyrights@tutorialsplane.com