我最终为Ionic的Alert控制器编写了一个包装提供程序,如下所示:
import { Injectable } from '@angular/core';
import { AlertController } from 'ionic-angular';
@Injectable()
export class Alert {
public alertPresented: any;
constructor(public alertCtrl: AlertController) {
this.alertPresented = false
}
present(title, subTitle) {
let vm = this
if(!vm.alertPresented) {
vm.alertPresented = true
vm.alertCtrl.create({
title: title,
subTitle: subTitle,
buttons: [{
text: 'OK',
handler: () => {
vm.alertPresented = false
}
}],
}).present();
}
}
}
Run Code Online (Sandbox Code Playgroud)
其中alertPresentedflag阻止呈现多个实例
| 归档时间: |
|
| 查看次数: |
5890 次 |
| 最近记录: |