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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -