feat($ionicLoading): add $ionicLoadingConfig constant for default options

Closes #1800
This commit is contained in:
Andrew
2014-07-21 08:22:43 -06:00
parent 7e20424a87
commit 26ca840dfc
3 changed files with 61 additions and 3 deletions

View File

@@ -32,8 +32,32 @@ var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been depre
* });
* ```
*/
/**
* @ngdoc object
* @name $ionicLoadingConfig
* @module ionic
* @description
* Set the default options to be passed to the {@link ionic.service:$ionicLoading} service.
*
* @usage
* ```js
* var app = angular.module('myApp', ['ionic'])
* app.constant('$ionicLoadingConfig', {
* template: 'Default Loading Template...'
* });
* app.controller('AppCtrl', function($scope, $ionicLoading) {
* $scope.showLoading = function() {
* $ionicLoading.show(); //options default to values in $ionicLoadingConfig
* };
* });
* ```
*/
IonicModule
.constant('$ionicLoadingConfig', {
template: '<i class="ion-loading-d"></i>'
})
.factory('$ionicLoading', [
'$ionicLoadingConfig',
'$document',
'$ionicTemplateLoader',
'$ionicBackdrop',
@@ -42,7 +66,7 @@ IonicModule
'$log',
'$compile',
'$ionicPlatform',
function($document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q, $log, $compile, $ionicPlatform) {
function($ionicLoadingConfig, $document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q, $log, $compile, $ionicPlatform) {
var loaderInstance;
//default values
@@ -151,7 +175,7 @@ function($document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q, $log, $c
}
function showLoader(options) {
options || (options = {});
options = extend($ionicLoadingConfig || {}, options || {});
var delay = options.delay || options.showDelay || 0;
//If loading.show() was called previously, cancel it and show with our new options