Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ionic Loading Action

ionic Loading Action

$ionicLoading is a default loading interaction effect in ionic. Its content can also be modified in a template.

Usage


angular.module('LoadingApp', ['ionic'])
.controller('LoadingCtrl', function($scope, $ionicLoading) {
  $scope.show = function() {
    $ionicLoading.show({
      template: 'Loading...'
    });
  };
  $scope.hide = function(){
    $ionicLoading.hide();
  };
});

Method

Show a loading effect.


show(opts)
Parameters Type Details
opts object

Options for the loading indicator. Available properties:

  • {string=} template The html content of the indicator.
  • {string=} templateUrl A url of a loading html template as the indicator's content.
  • {boolean=} noBackdrop Whether to hide the backdrop. By default it is shown.
  • {number=} delay How many milliseconds to delay showing the indicator. Default is no delay.
  • {number=} duration How many milliseconds to wait before automatically hiding the indicator. By default, the indicator stays shown until.hide()。
  • |

    Hide a loading effect.

    
    hide()
    

    API

    property Type Details
    delegate-handle

    (optional)

    | `string` |

    This handle defines a list with$ionicListDelegate.

    | | show-delete
    (optional)
    | `boolean` |

    Whether the delete button of the list item is currently shown or hidden.

    | | show-reorder
    (optional)
    | `boolean` |

    Whether the sort button of the list item is currently shown or hidden.

    | | can-swipe
    (optional)
    | `boolean` |

    Whether the list item is allowed to slide to reveal option buttons. Default: true.

    |

    Example

    HTML code:

    
    
      
        
         
        
        Ionic Modal
    
         
        
      
      
        
          
            
              

    The Stooges

    {{stooge.name}}

    JavaScript Code

    
    angular.module('ionicApp', ['ionic'])
    .controller('AppCtrl', function($scope, $timeout, $ionicLoading) {
    
      // Setup the loader
      $ionicLoading.show({
        content: 'Loading',
        animation: 'fade-in',
        showBackdrop: true,
        maxWidth: 200,
        showDelay: 0
      });
      
      // Set a timeout to clear loader, however you would actually call the $ionicLoading.hide(); method whenever everything is ready or loaded.
      $timeout(function () {
        $ionicLoading.hide();
        $scope.stooges = [{name: 'Moe'}, {name: 'Larry'}, {name: 'Curly'}];
      }, 2000);
      
    });
    


    $ionicLoadingConfig

    Set the default options for loading:

    Usage:

    
    var app = angular.module('myApp', ['ionic'])
    app.constant('$ionicLoadingConfig', {
      template: '默认加载模板……'
    });
    app.controller('AppCtrl', function($scope, $ionicLoading) {
      $scope.showLoading = function() {
        $ionicLoading.show(); //配置选项在 $ionicLoadingConfig 设置
      };
    });