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();
}
}]);