Created
July 27, 2016 23:40
-
-
Save MCheli/79a1fa972a421c2f897a204c8e071378 to your computer and use it in GitHub Desktop.
Ionic Global Loading Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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