@@ -5,10 +5,6 @@ var LOADING_TPL =
5
5
'</div>' +
6
6
'</div>' ;
7
7
8
- var LOADING_HIDE_DEPRECATED = '$ionicLoading instance.hide() has been deprecated. Use $ionicLoading.hide().' ;
9
- var LOADING_SHOW_DEPRECATED = '$ionicLoading instance.show() has been deprecated. Use $ionicLoading.show().' ;
10
- var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been deprecated. Use $ionicLoading.show({ template: \'my content\' }).' ;
11
-
12
8
/**
13
9
* @ngdoc service
14
10
* @name $ionicLoading
@@ -24,10 +20,14 @@ var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been depre
24
20
* $scope.show = function() {
25
21
* $ionicLoading.show({
26
22
* template: 'Loading...'
23
+ * }).then(function(){
24
+ * console.log("The loading indicator is now displayed");
27
25
* });
28
26
* };
29
27
* $scope.hide = function(){
30
- * $ionicLoading.hide();
28
+ * $ionicLoading.hide().then(function(){
29
+ * console.log("The loading indicator is now hidden");
30
+ * });
31
31
* };
32
32
* });
33
33
* ```
@@ -47,7 +47,10 @@ var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been depre
47
47
* });
48
48
* app.controller('AppCtrl', function($scope, $ionicLoading) {
49
49
* $scope.showLoading = function() {
50
- * $ionicLoading.show(); //options default to values in $ionicLoadingConfig
50
+ * //options default to values in $ionicLoadingConfig
51
+ * $ionicLoading.show().then(function(){
52
+ * console.log("The loading indicator is now displayed");
53
+ * });
51
54
* };
52
55
* });
53
56
* ```
@@ -82,9 +85,8 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
82
85
* @ngdoc method
83
86
* @name $ionicLoading#show
84
87
* @description Shows a loading indicator. If the indicator is already shown,
85
- * it will set the options given and keep the indicator shown. Note: While this
86
- * function still returns an $ionicLoading instance for backwards compatiblity,
87
- * its use has been deprecated.
88
+ * it will set the options given and keep the indicator shown.
89
+ * @returns {promise } A promise which is resolved when the loading indicator is presented.
88
90
* @param {object } opts The options for the loading indicator. Available properties:
89
91
* - `{string=}` `template` The html content of the indicator.
90
92
* - `{string=}` `templateUrl` The url of an html template to load as the content of the indicator.
@@ -101,6 +103,7 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
101
103
* @ngdoc method
102
104
* @name $ionicLoading#hide
103
105
* @description Hides the loading indicator, if shown.
106
+ * @returns {promise } A promise which is resolved when the loading indicator is hidden.
104
107
*/
105
108
hide : hideLoader ,
106
109
/**
@@ -198,6 +201,8 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
198
201
199
202
function showLoader ( options ) {
200
203
options = extend ( { } , $ionicLoadingConfig || { } , options || { } ) ;
204
+ // use a default delay of 100 to avoid some issues reported on github
205
+ // https://github.com/driftyco/ionic/issues/3717
201
206
var delay = options . delay || options . showDelay || 0 ;
202
207
203
208
deregisterStateListener1 ( ) ;
@@ -210,34 +215,17 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
210
215
//If loading.show() was called previously, cancel it and show with our new options
211
216
$timeout . cancel ( loadingShowDelay ) ;
212
217
loadingShowDelay = $timeout ( noop , delay ) ;
213
- loadingShowDelay . then ( getLoader ) . then ( function ( loader ) {
218
+ return loadingShowDelay . then ( getLoader ) . then ( function ( loader ) {
214
219
return loader . show ( options ) ;
215
220
} ) ;
216
-
217
- return {
218
- hide : function deprecatedHide ( ) {
219
- $log . error ( LOADING_HIDE_DEPRECATED ) ;
220
- return hideLoader . apply ( this , arguments ) ;
221
- } ,
222
- show : function deprecatedShow ( ) {
223
- $log . error ( LOADING_SHOW_DEPRECATED ) ;
224
- return showLoader . apply ( this , arguments ) ;
225
- } ,
226
- setContent : function deprecatedSetContent ( content ) {
227
- $log . error ( LOADING_SET_DEPRECATED ) ;
228
- return getLoader ( ) . then ( function ( loader ) {
229
- loader . show ( { template : content } ) ;
230
- } ) ;
231
- }
232
- } ;
233
221
}
234
222
235
223
function hideLoader ( ) {
236
224
deregisterStateListener1 ( ) ;
237
225
deregisterStateListener2 ( ) ;
238
226
$timeout . cancel ( loadingShowDelay ) ;
239
- getLoader ( ) . then ( function ( loader ) {
240
- loader . hide ( ) ;
227
+ return getLoader ( ) . then ( function ( loader ) {
228
+ return loader . hide ( ) ;
241
229
} ) ;
242
230
}
243
231
} ] ) ;
0 commit comments