天天看点

如何在ionic中添加加载提示

使用方法

angular.module('ionicApp', ['ionic'])

.controller('AppCtrl', function($scope, $timeout, $ionicLoading) {

 // Setup the loader

 $ionicLoading.show({

   content: 'Loading',

   animation: 'fade-in',

   showBackdrop: false,

   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);

方法

show(opts) 显示加载提示

{string=} template html模板

{string=} templateUrl 通过url加载模板

{object=} scope 作用域. 默认是$rootScope.

{boolean=} noBackdrop Whether to hide the backdrop. By default it will be shown.

{boolean=} hideOnStateChange Whether to hide the loading spinner when navigating to a new state. Default false.

{number=} delay 延迟显示,多少毫秒后显示加载提示

{number=} duration 自动隐藏,多少毫秒后自动隐藏加载提示。默认是不自动隐藏

hide() 隐藏加载提示