2

I have to include a external webpage in my app, so I use an iframe for this. Now I want to show an loading animation, while the iframe is loading. That works fine, but I don't know, how to dismiss the animation, when the iframe is ready. I can't edit the code of the page in the iframe.

That's my code on the TypeScript-File:

ngOnInit() {
    this.presentLoading();
}

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

    loading.present();
}

and the HTML file

<ion-content>
    <iframe name="chatFrame" src="http://..."></iframe>
</ion-content>
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
  • I believe this question may have been answer here: [Checking Load State on an Iframe](http://stackoverflow.com/questions/17158932/how-to-detect-when-an-iframe-has-already-been-loaded/36155560#36155560) – Chad Fisher Feb 16 '17 at 16:08

2 Answers2

2

Attach onLoad iframe method to a function that will dismiss your loading animation.

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

And in your component class :

loading;

ngOnInit() {
    this.presentLoading();
}

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

    loading.present();
}

dismissLoading(){
    this.loading.dismiss();
}
Nicolas Law-Dune
  • 1,631
  • 2
  • 13
  • 30
0

The answer above is wrong, I modify it and it can run perfectly:

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