May 22, 2021 ionic
$ionicLoading is a load interaction by ionic default. The contents can also be modified inside the template.
angular.module('LoadingApp', ['ionic']) .controller('LoadingCtrl', function($scope, $ionicLoading) { $scope.show = function() { $ionicLoading.show({ template: 'Loading...' }); }; $scope.hide = function(){ $ionicLoading.hide(); }; });
Displays a load effect.
show(opts)
Parameters | Type | Details |
---|---|---|
opts |
object
|
The option of the loading indicator. Available properties:
|
Hide a load effect.
hide()
Property | Type | Details |
---|---|---|
delegate-handle
(Optional)
|
字符串
|
The handle defines a
|
show-delete
(Optional)
|
布尔值
|
The delete button for the list item is currently displayed or hidden. |
show-reorder
(Optional)
|
布尔值
|
The sort button for list items is currently displayed or hidden. |
can-swipe
(Optional)
|
布尔值
|
Whether the list item is allowed to slide the Display Options button. Default: true. |
<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="//www.w3cschool.cn/statics/demosource/ionic.min.css" rel="stylesheet"> <script src="//www.w3cschool.cn/statics/demosource/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>
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); });
Set the default option for loading:
var app = angular.module('myApp', ['ionic']) app.constant('$ionicLoadingConfig', { template: '默认加载模板……' }); app.controller('AppCtrl', function($scope, $ionicLoading) { $scope.showLoading = function() { $ionicLoading.show(); //配置选项在 $ionicLoadingConfig 设置 }; });