Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

timeOut in ionic 2

$
0
0

@dbertels wrote:

When calling this.nav.setRoot() from an Alert component, the screen tends to go blank, A work-around this is to give the app some time to load by calling timeOut(). Being new to Angular 2, I managed to make this work as follows:

createAlert() {
    let confirm = Alert.create({
        title: 'Form Completed',
        body: '<p>Form has now been completed and signed by a witness</p>',
        buttons: [{
            text: 'OK',
            handler: () => {
                this.createTimeout(300)
                .then(() => {
                    console.log(`done after 300ms delay`)
                    this.nav.setRoot(AcdSelectionPage);
                })
            }
        }]
    });
        this.nav.present(confirm);
    }

    createTimeout(timeout) {
        return new Promise((resolve, reject) => {
            setTimeout(() => resolve(null),timeout)
        })
    }

My question is two-fold:
1) Is there an easier way to implement the timeOut()?
2) Is there a better way of allowing the page to load fully (without using timeOut)?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>