ionic LoadingController 模块使用

html 代码:


<
ion-header> <ion-navbar> <ion-title>Loading</ion-title> </ion-navbar> </ion-header> <ion-content class="outer-content"> <ion-list> <ion-list-header> Spinner Loading Indicators </ion-list-header> <button ion-item (click)="presentLoadingIos()"> <ion-spinner item-start name="ios"></ion-spinner> Show iOS </button> <button ion-item (click)="presentLoadingDots()"> <ion-spinner item-start name="dots"></ion-spinner> Show Dots </button> <button ion-item (click)="presentLoadingBubbles()"> <ion-spinner item-start name="bubbles"></ion-spinner> Show Bubbles </button> <button ion-item (click)="presentLoadingCircles()"> <ion-spinner item-start name="circles"></ion-spinner> Show Circles </button> <button ion-item (click)="presentLoadingCrescent()"> <ion-spinner item-start name="crescent"></ion-spinner> Show Crescent </button> <button ion-item (click)="presentLoadingDefault()"> <ion-spinner item-start></ion-spinner> Show Default </button> </ion-list> <ion-list> <ion-list-header> Custom Loading Indicators </ion-list-header> <button ion-item (click)="presentLoadingCustom()"> Show Custom </button> <button ion-item (click)="presentLoadingText()"> Show Text Only </button> </ion-list> </ion-content> <ion-footer> <ion-toolbar> <ion-buttons end> <button ion-button icon-end (click)="goToPage2()"> Show Loading and Navigate <ion-icon name="arrow-forward"></ion-icon> </button> </ion-buttons> </ion-toolbar> </ion-footer>

 

.ts 文件: 


import { Component } from '@angular/core'; import { LoadingController, NavController } from '../../../../../src'; import { PageTwo } from '../page-two/page-two'; @Component({ templateUrl: 'page-one.html' }) export class PageOne { constructor(public loadingCtrl: LoadingController, public navCtrl: NavController) {} presentLoadingIos() { let loading = this.loadingCtrl.create({ spinner: 'ios', content: 'This is the "ios" spinner. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } presentLoadingDots() { let loading = this.loadingCtrl.create({ spinner: 'dots', content: 'This is the "dots" spinner. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } presentLoadingBubbles() { let loading = this.loadingCtrl.create({ spinner: 'bubbles', content: 'This is the "bubbles" spinner. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } presentLoadingCircles() { let loading = this.loadingCtrl.create({ spinner: 'circles', content: 'This is the "circles" spinner. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } presentLoadingCrescent() { let loading = this.loadingCtrl.create({ spinner: 'crescent', content: 'This is the "crescent" spinner. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } presentLoadingDefault() { let loading = this.loadingCtrl.create({ content: 'This is the mode specific spinner. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } presentLoadingCustom() { let loading = this.loadingCtrl.create({ spinner: 'hide', content: ` <div class="loading-custom-spinner-container"> <div class="loading-custom-spinner-box"></div> </div> <div>This is a custom spinner. It will dismiss after 3 seconds.</div>`, duration: 3000 }); loading.present(); } presentLoadingText() { let loading = this.loadingCtrl.create({ spinner: 'hide', content: 'This has no spinner, only text. It will dismiss after 3 seconds.', duration: 3000 }); loading.present(); } goToPage2() { let loading = this.loadingCtrl.create({ content: 'This will navigate to the next page and then dismiss after 3 seconds.' }); loading.present(); setTimeout(() => { this.navCtrl.push(PageTwo); }, 1000); setTimeout(() => { loading.dismiss(); }, 4000); } }

 

posted @ 2018-05-19 17:31  睡到自然醒ccc  阅读(2446)  评论(0编辑  收藏  举报