$http.get('http://api.getchill.co/api/v1/messages/index/id_user/'+$rootScope.userData.id_user+'/id_contact/'+$stateParams.id)
.success(function(data) {
$scope.messages = data;
angular.forEach($scope.messages.response, function(response, i){
if (response.type == 'location') {
var strings = response.content.split(' ');
var lat1 = strings[0], lat2 = strings[1];
$http.get('http://maps.googleapis.com/maps/api/geocode/json?latlng='+lat1+','+lat2+'&sensor=false')
.success(function(data) {
$ionicLoading.hide();
response.address = data.results[0].formatted_address;
});
};
});
$ionicSlideBoxDelegate.update();
});
$http.get('http://api.getchill.co/api/v1/messages/index/id_user/'+$rootScope.userData.id_user+'/id_contact/'+$stateParams.id)
.success(function(data) {
$scope.messages = data;
for (var i = 0; i < $scope.messages.response.length; ++i) {
if ($scope.messages.response[i].type == 'location') {
var strings = $scope.messages.response[i].content.split(' ');
var lat1 = strings[0], lat2 = strings[1];
$http.get('http://maps.googleapis.com/maps/api/geocode/json?latlng='+lat1+','+lat2+'&sensor=false')
.success(function(data) {
$ionicLoading.hide();
$scope.messages.response[i]['formatted_address'] = data.results[0].formatted_address;
});
};
};
$ionicSlideBoxDelegate.update();
});