javascript - AngularJS returning to html from http -
this question has answer here:
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
Post a Comment