javascript - AngularJS: Call httpget on value change from textbox -


i have web service returns json file on call parameter id of entry. have angular method returns data returned method. have no idea how recall service when input of id has changed want recall method when new value has been supplied.

the parameter pass in id called reference. html returns object reference of 1234 if change value dont know how recall service.

this have far:

angular:

var app = angular.module("mymodule", []) .controller("mycontroller", function ($scope, $http) {     var res = $http({         method: 'get',         url: 'airportrwebservice.asmx/dashboarddetail',         params: { reference : '1234' }     })     .then(function (response) {         $scope.booking = response.data     });     $scope.test = "angular method called";     $scope.reference = '1234';  }); 

html

<!doctype html> <html> <head>     <script src="scripts/angular.js"></script>     <script src="app/newapptwo.js"></script> </head> <body ng-app="mymodule" ng-controller="mycontroller">     {{test}}     {{reference}}     <br />     <br />     <input type="text" ng-model="reference" ng-change="booking"/>      {{booking}} </body> </html> 

change ng-change="booking" function called everytime models refences changes:

$scope.getreference = function(referencenumber){   $http({          method: 'get',          url: 'airportrwebservice.asmx/dashboarddetail',          params: { reference :  referencenumber}   }).function (response) {      $scope.booking = response.data   }); }  <input type="text" ng-model="reference" ng-change="getreference(reference)"/> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -