$ionicLoading 是 ionic 默認的一個加載交互效果。裏面的內容也是能夠在模板裏面修改。php
angular.module('LoadingApp', ['ionic']) .controller('LoadingCtrl', function($scope, $ionicLoading) { $scope.show = function() { $ionicLoading.show({ template: 'Loading...' }); }; $scope.hide = function(){ $ionicLoading.hide(); }; });
顯示一個加載效果。css
show(opts)
參數 | 類型 | 詳情 |
---|---|---|
opts | object |
loading指示器的選項。可用屬性:html
|
隱藏一個加載效果。android
hide()
屬性 | 類型 | 詳情 |
---|---|---|
delegate-handle
(可選)
|
字符串 |
該句柄定義帶有 |
show-delete
(可選)
|
布爾值 |
列表項的刪除按鈕當前是顯示仍是隱藏。app |
show-reorder
(可選)
|
布爾值 |
列表項的排序按鈕當前是顯示仍是隱藏。ionic |
can-swipe
(可選)
|
布爾值 |
列表項是否被容許滑動顯示選項按鈕。默認:true。ide |
<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.runoob.com/static/ionic/css/ionic.min.css" rel="stylesheet"> <script src="http://www.runoob.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>
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); });
設置加載的默認選項:svg
var app = angular.module('myApp', ['ionic']) app.constant('$ionicLoadingConfig', { template: '默認加載模板……' }); app.controller('AppCtrl', function($scope, $ionicLoading) { $scope.showLoading = function() { $ionicLoading.show(); //配置選項在 $ionicLoadingConfig 設置 }; });
ionSpinner 提供了許多種旋轉加載的動畫圖標。當你的界面加載時,你就能夠呈現給用戶相應的加載圖標。動畫
該圖標採用的是SVG。
<ion-spinner icon="spiral"></ion-spinner> //默認用法
像大部分其餘的ionic組件同樣,spinner也可使用ionic的標準顏色命名規則,就像下面這樣:
<ion-spinner class="spinner-energized"></ion-spinner>
<ion-content scroll="false" class="has-header"> <p> <ion-spinner icon="android"></ion-spinner> <ion-spinner icon="ios"></ion-spinner> <ion-spinner icon="ios-small"></ion-spinner> <ion-spinner icon="bubbles" class="spinner-balanced"></ion-spinner> <ion-spinner icon="circles" class="spinner-energized"></ion-spinner> </p> <p> <ion-spinner icon="crescent" class="spinner-royal"></ion-spinner> <ion-spinner icon="dots" class="spinner-dark"></ion-spinner> <ion-spinner icon="lines" class="spinner-calm"></ion-spinner> <ion-spinner icon="ripple" class="spinner-assertive"></ion-spinner> <ion-spinner icon="spiral"></ion-spinner> </p> </ion-content>
body { cursor: url('http://www.runob.com/try/demo_source/finger.png'), auto; } p { text-align: center; margin-bottom: 40px !important; } .spinner svg { width: 19% !important; height: 85px !important; }
angular.module('ionicApp', ['ionic']) .controller('MyCtrl', function($scope) { });