Reputation: 349
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 .
Upvotes: 0
Views: 86
Reputation: 486
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
Upvotes: 1
Reputation: 6619
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);
});
});
Upvotes: 1