I take from here
This is mi code
Service
.factory('LoaderService', function($rootScope, $ionicLoading) {
return {
show : function() {
$rootScope.loading = $ionicLoading.show({
content: '<i class="icon ion-loading-c"></i>',
animation: 'fade-in',
showBackdrop: true,
minWidth: 200,
showDelay: 10
});
},
hide : function(){
$ionicLoading.hide();
}
}
});
Controller
.controller('MyCtrl', function($scope, $timeout, $rootScope, LoaderService, OtherService) {
LoaderService.show();
OtherService.getData(function(dataResponse) {
$scope.data = dataResponse;
LoaderService.hide();
});
});
I use LoaderService in all controllers
Another approach can be see here: