Reputation: 1617
Loading component in ionic 2 working fine, for present the loading i've used below code.
let loading = Loading.create({
content: "Please wait..."
});
this.nav.present(this.loading);
but my Question when i've using this.loading.dimiss();
it's not working any suggestions plz ?
Upvotes: 0
Views: 1399
Reputation: 584
Are you calling this from a callback of an Asynchronous function?
If so you will have to do something like
let loading = Loading.create({
content: "Please wait..."
});
this.nav.present(this.loading);
let me = this;
asyncFunction.load(me)
.then(data => {
......... do something with data ........
// when ready close loading
me.loading.dismiss();
});
You need to pass a reference to this into the asynchronous function so you can keep a reference to it available to the callback
Upvotes: 1
Reputation: 1617
I solved it by puting the code after dismiss()
in the .then()
of the promise that the dismiss()
function returns.
eg : this.loading.dismiss().then(() => { /* PUT YOUR CODE HERE */ })
Upvotes: 0