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

'hasOwnProperty' in javascript -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

android - Unable to generate FCM token from dynamically instantiated Firebase -