Latest web development tutorials

ionic load operation

$ IonicLoading is ionic load a default interaction effect. You can also modify the contents inside the template inside.

usage

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

method

Display a loading effect.

show(opts)
parameter Types of Detail
opts object

loading indicator option. Available properties:

  • {string=} template indicator html content.
  • {string=} templateUrl a load url html template as a content indicator.
  • {boolean=} noBackdrop is hidden background. By default, it will show.
  • {number=} delay indicator displays how many milliseconds delay. The default is not delayed.
  • {number=} duration wait how many milliseconds after the auto-hide indicator. By default, the indicator continues to display until the trigger .hide() .

Hide a loading effect.

hide()

API

Attributes Types of Detail
delegate-handle
(Optional)
字符串

The handle is defined with $ionicListDelegate list.

show-delete
(Optional)
布尔值

Delete button list of items currently displayed or hidden.

show-reorder
(Optional)
布尔值

Sort button list items currently displayed or hidden.

can-swipe
(Optional)
布尔值

Whether the list item is allowed to slide display options button. Default: true.


Examples

HTML code:

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
    
    <title>Ionic Modal</title>

     <link href="http://www.w3big.com/static/ionic/css/ionic.min.css" rel="stylesheet">
    <script src="http://www.w3big.com/static/ionic/js/ionic.bundle.min.js"></script>
  </head>
  <body ng-controller="AppCtrl">
    
      <ion-view title="Home">
        <ion-header-bar>
          <h1 class="title">The Stooges</h1>
        </ion-header-bar>
        <ion-content has-header="true">
          <ion-list>
            <ion-item ng-repeat="stooge in stooges" href="#">{{stooge.name}}</ion-item>
          </ion-list>
        </ion-content>
      </ion-view>
    
  </body>
</html>

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 to load:

usage:

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