javascript - AngularJS returning to html from http -


i'm trying return angular function html success function of http request. in case, i'm using google api miles, want return html won't return unless it's in main function.

this code in controller :

$scope.getdistance=function(pcodefrom,pcodeto,id){

if($scope.milesgot.indexof(id) == -1) { //if not done request once      $scope.milesgot.push(id);  var url = 'mylinktogooglematrixapiishere';   $http({method: 'get', url: url}).success(function(data) {                    var = data.destination_addresses;                    var = data.destination_addresses;                     var miles = data.rows[0].elements[0].distance.text;                     return miles;                  }).error(function(data){                  });          }       } 

the 'miles' variable fine, when change plain text "test" won't return.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -