【问题标题】:Ionic 2: Dismiss loading animation when iframe is readyIonic 2:当 iframe 准备好时关闭加载动画
【发布时间】:2017-07-05 20:31:26
【问题描述】:

我必须在我的应用中包含一个外部网页,所以我为此使用了 iframe。 现在我想在 iframe 加载时显示加载动画。这很好用,但我不知道当 iframe 准备好时如何关闭动画。 我无法在 iframe 中编辑页面的代码。

这是我在 TypeScript-File 上的代码:

ngOnInit() {
    this.presentLoading();
}

presentLoading() {
    let loading = this.loadingCtrl.create({
        content: 'Please wait...'
    });

    loading.present();
}

和 HTML 文件

<ion-content>
    <iframe name="chatFrame" src="http://..."></iframe>
</ion-content>

【问题讨论】:

标签: html angular iframe typescript ionic-framework


【解决方案1】:

将 onLoad iframe 方法附加到将关闭加载动画的函数。

<ion-content>
    <iframe name="chatFrame" src="http://..." (load)="dismissLoading()"></iframe>
</ion-content>

在你的组件类中:

loading;

ngOnInit() {
    this.presentLoading();
}

presentLoading() {
    this.loading = this.loadingCtrl.create({
       content: 'Please wait...'
    });

    loading.present();
}

dismissLoading(){
    this.loading.dismiss();
}

【讨论】:

  • 我试过这个,但我得到“this.loading.dismiss() is not a function”
【解决方案2】:

上面的答案是错误的,我修改一下就可以完美运行了:

dismissLoading(){
   //this.loading.dismiss();
     this.loadingCtrl.dismiss();
}

【讨论】:

    猜你喜欢
    • 2015-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 2013-06-24
    • 1970-01-01
    • 2011-10-01
    相关资源
    最近更新 更多