mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicLoading): add $ionicLoadingConfig constant for default options
Closes #1800
This commit is contained in:
28
js/angular/service/loading.js
vendored
28
js/angular/service/loading.js
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user