bug: bug: $ionicLoading Not Being Removed
See original GitHub issueType: <span ionic-type>bug</span>
Platform: <span ionic-platform>android</span> <span ionic-platform-version>4.4</span> <span ionic-webview>webview</span>
<span ionic-description>Type: <span ionic-type>bug</span>
Platform: <span ionic-platform>android</span> <span ionic-platform-version>4.4</span> <span ionic-webview>webview</span>
<span ionic-description>Hi, I have a case where in my Resolve for a route, I get some data from the local DB.
resolve: {
CategoriesList: ['Category', '$ionicLoading', function(Category, $ionicLoading) {
$ionicLoading.show({
template: 'Loading Categories',
noBackdrop: true
});
return Category.getAllLocalCategories()
.then(function(allLocalCategoriesSuccessData) {
$ionicLoading.hide();
return {
categories: allLocalCategoriesSuccessData,
success: true
};
}, function() {
$ionicLoading.hide();
return {
success: false
};
});
}]
}
The code above shows how I handle my flow by showing the $ionicLoading and then hiding it asap I get something. This code has always worked since up until RC3. Updating to RC4 RC5 including Stable 1.0.0 seems to make sure that the $ionicLoading stays open. The funny part is it happens only on Android. On IOS the code works as normal but on Android (Both IONIC Serve & Ionic Device), It breaks. I have a video showing proof. </span>
<span is-issue-template></span> </span>
<span is-issue-template></span>
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (9 by maintainers)
I’ve had similar problem (
$ionicLoading.hide()
not working ) when I implemented localStorage cache in my App. I have debugged with lots of console.logs everywhere because I had not a single error on the console. I came the the conclusion that retrieving cached data was so quick that$ionicLoading.hide()
finishes execution before$ionicLoading.show()
.What solved for me was:
$timeout( function(){ $ionicLoading.hide()},100);
I have seen this hack before on Titanium with Android, so I guess it has something to do with the way Android code is processed…EDIT
If you do
$ionicLoading.show({delay:100})
and then$ionicLoading.hide()
it works, I mean, if the two calls are done very fast ( less then 100ms ) loading is never show, what is supposed to be expected. I think that the show call is registered and the hide call cancels it. Obviously! But when you do not use the delay option, the show call spends some time executing itself (async, my guess) while the hide call gets executed (and hides nothing) resulting loading to stay opened forever.@ffabreti Thanks a lot. I was really struggling with this issue, but your solution saved my day.