Loading does not dismiss properly

I creating two loading components one after the other the second loading component will never dismiss. Sometimes the loading component gets hidden and the overlay still appears on the page.

let loading = this.loadingCtrl.create({
   spinner: 'hide',
   content: 'Loading Please Wait...'
});
loading.present();
loading.dismiss().then(() => {
    //Second loading component
    let loading2 = this.loadingCtrl.create({
        spinner: 'hide',
        content: 'Loading Please Wait...'
    }); 
    loading2.present();
    loading2.dismiss();
})

Ionic Info:
Cordova : 6.4.0
Ionic Framework Version: 2.0.0-rc.6

Anyone facing this issue?

Well… You’re never dismissing loading2? And maybe you should also be using the promise when you present(), before you dismiss.

Hello, I have updated the code, I forgot to add the dismiss. When I call the dismiss for the loading2 it does not dismiss. It stays forever.

I also tried this way but still the loading2 stays

loading2.present().then(() => {
   loading2.dismiss();
})

Try this

let loading = this.loadingCtrl.create({
	spinner: "hide",
	content: "Loading Please Wait..."
});
loading.present().then(() => {
	loading.dismiss().then(() => {
		//Second loading component
		let loading2 = this.loadingCtrl.create({
			spinner: "hide",
			content: "Loading Please Wait... (2)"
		}); 
		loading2.present().then(() => {
			loading2.dismiss();
		});
	});
});

That is what it should look like after you edited it. If that was what it looked like, which one is stuck? The one with “(2)” in it?

Hello, I tried the above way but still the “(2)” does not dismiss

Then I have to assume it’s something with your dependencies :confused: It works fine for me, here’s my stuff:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.1.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.3
ios-deploy version: 1.9.0
ios-sim version: 5.0.12
OS: macOS Sierra
Node Version: v6.10.0
Xcode version: Xcode 8.2.1 Build version 8C1002
"dependencies": {
	"@angular/common": "2.2.1",
	"@angular/compiler": "2.2.1",
	"@angular/compiler-cli": "2.2.1",
	"@angular/core": "2.2.1",
	"@angular/forms": "2.2.1",
	"@angular/http": "2.2.1",
	"@angular/platform-browser": "2.2.1",
	"@angular/platform-browser-dynamic": "2.2.1",
	"@angular/platform-server": "2.2.1",
	"@ionic/cloud-angular": "^0.9.1",
	"@ionic/storage": "1.1.9",
	"ionic-angular": "2.1.0",
	"ionic-app-lib": "2.2.0",
	"ionic-native": "2.4.1",
	"ionicons": "3.0.0",
	"ng2-pdf-viewer": "^1.0.2",
	"ng2-translate": "4.2.0",
	"rxjs": "5.0.0-beta.12",
	"sw-toolbox": "3.4.0",
	"zone.js": "0.6.26"
},
"devDependencies": {
	"@ionic/app-scripts": "1.1.3",
	"typescript": "2.0.9"
}