ionicLoading.hide() not working

Hi All, I created the service below and not sure where should I add the ionicLoading functionality?

I put in the code below (you will see it commented out) and it works but the ionicLoading.hide(), don’t.

angular.module(‘starter’)
.service(‘TwitterService’,[’$http’,’$ionicLoading’,’$cordovaGeolocation’, function($http, $ionicLoading, $cordovaGeolocation){

var lat = "";
var long = "";

var geoSettings = {frequency: 1000, timeout: 30000, enableHighAccuracy: false};

$cordovaGeolocation.getCurrentPosition(geoSettings).
then(function (position) {
    lat = position.coords.latitude;
    long = position.coords.longitude;
    console.log("Twitter latitude: "+lat);
    console.log("Twitter longitude: "+long);
     
},
    function error(error) {
        alert('code: ' + error.code + '\n' +
        'message: ' + error.message + '\n');
    }
);

this.getTwitter = function(hashtag){

	console.log("Hashtag: "+hashtag);
	//$ionicLoading.show();

	return $http({			
		method: 'GET', 
		url: 'https://catastrophe-advisor-twitter.mybluemix.net/api/twitter/count?lat='+lat+'&lng='+long+'&keywords='+hashtag+'',
		data: hashtag			
	});
	ionicLoading.hide();
}

}]);

maybe you should put a time duration for ionic loading($timeout).

You have to use **$**ionicLoading, not ionicLoading, unless you renamed it somewhere.

1 Like

Thanks for the reply but it was just a typo.

 $http(ALL THE THINGS).then ( 
    function (success) { 
          $ionicLoading.hide();
          return success.data; // or something
    }, 
    function (fail) { 
          $ionicLoading.hide();
    }
 );