0
    google.maps.event.addListener(marker, 'dragend', function() {
       getmydata = function() {
            return $http.get("getConnectionData.php").then(function (response) {
                         $scope.links1 = response.data.records;
                   });

               }

              getmydata().then(function(data) {
              // stuff is now in our scope, I can alert it
              console.log("hiiiii" , $scope.links1);
              });


 });

Here I want to call this section outside of dragend function- google.maps.event.addListener(marker, 'dragend', function() {

getmydata().then(function(data) {
    // stuff is now in our scope, I can alert it
     console.log("hiiiii" , $scope.links1);
});

How can I do this .

2 Answers 2

1

You need to return data from the $http.get call

 google.maps.event.addListener(marker, 'dragend', function() {
   getmydata = function() {
       return $http.get("getConnectionData.php").then(function (response) {
                 return response;
           });
       }

      getmydata().then(function(data) {
      // stuff is now in our scope, I can alert it
      $scope.links1 = data;
      console.log("hiiiii" , $scope.links1);
      });
 });
Sign up to request clarification or add additional context in comments.

1 Comment

I am returning the data from $http.get $scope.links1 = data;
1

you can write something like this

   getmydata2=function(data){
      console.log("hiiiii" , data);
   }

   getmydata = function() {
        return $http.get("getConnectionData.php").then(function (response) {
                     $scope.links1 = response.data.records;
                     getmydata2($scope.links1);
               });

   }

 google.maps.event.addListener(marker, 'dragend', getmydata);

you can now call it wherever you want

4 Comments

I want the data after drag function..Because I need updated data and when I am making drag I am getting updated data
check it out once again plz
TypeError: f.j.apply is not a function
use google.maps.event.addListener(marker, 'dragend', getmydata);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.