Skip to content

Instantly share code, notes, and snippets.

@MCheli
Created July 27, 2016 23:40
Show Gist options
  • Save MCheli/79a1fa972a421c2f897a204c8e071378 to your computer and use it in GitHub Desktop.
Save MCheli/79a1fa972a421c2f897a204c8e071378 to your computer and use it in GitHub Desktop.
Ionic Global Loading Bar
.run(function($ionicPlatform, $rootScope, $ionicLoading) {
$ionicPlatform.ready(function () {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
$rootScope.$on('loading:show', function () {
$ionicLoading.show({
template: '<ion-spinner></ion-spinner> Loading ...'
})
});
$rootScope.$on('loading:hide', function () {
$ionicLoading.hide();
});
$rootScope.$on('$stateChangeStart', function () {
console.log('Loading ...');
$rootScope.$broadcast('loading:show');
});
$rootScope.$on('$stateChangeSuccess', function () {
console.log('done');
$rootScope.$broadcast('loading:hide');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment