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

ionic Backdrop

ionic Backdrop

We often need to show or hide a backdrop in the UI, such as in popups, loading boxes, and other pop-up layers.

In a component you can use $ionicBackdrop.retain() to show the backdrop and $ionicBackdrop.release() to hide it.

After each call to retain, the backdrop remains shown until release is called to remove it.


Example

HTML Code



    
        
            

$ionicBackdrop

    
    

JavaScript Code


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

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.controller( 'actionsheetCtl',['$scope','$timeout' ,'$ionicBackdrop',function($scope,$timeout,$ionicBackdrop){

    $scope.action = function() {
       $ionicBackdrop.retain();
       $timeout(function() {    //默认让它1秒后消失
         $ionicBackdrop.release();
       }, 1000);
    }; 
}])

The display effect is shown below: