# Loading controller .dismiss()

**URL:** <https://forum.ionicframework.com/t/loading-controller-dismiss/70601>\
**Category:** ionic-v3\
**Created:** [November 18, 2016, 11:31am UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601 "2016-11-18T11:31:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewgy8](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/andrewgy8/32/106716_2.png) [@andrewgy8](https://forum.ionicframework.com/u/andrewgy8)\
**Post date:** [November 18, 2016, 11:31am UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/1 "2016-11-18T11:31:32Z")

</div>

Im sure Im missing something simple.

I have a subscription that returns a boolean. When I subscribe to it the first time, the loading boolean is ‘true’ but when the loading is completed, it return ‘false’.

So why does my loading screen not disappear?

```
ngOnInit() { 
    this.isLoading$ = this.store.let(fromRoot.getIaReportsIsLoading);
    this.isLoading$.subscribe((currentLoading: boolean) => {
        this.presentLoading(currentLoading)
    })
}

 presentLoading(isLoading: boolean) {
    let loader = this.loadingCtrl.create({
        content: "Please wait while we load all Interaction Reports and Clients for you...",
    });
    console.log('currentLoading', isLoading)
    isLoading ? loader.present() : loader.dismiss();

```

Edit: I changed the scope of the loading controller, but this did nothing for the dismissal behaviour.

```
 presentLoading(isLoading: boolean) {
    this.loader = this.loadingCtrl.create({
        content: "Please wait while we load all Interaction Reports and Clients for you...",
    });
    console.log('currentLoading', isLoading)
    isLoading ? this.loader.present() : this.loader.dismiss();
};

```

Everything else is the same

EDIT2: Im almost positive that this is context issue. So I tried this:

```
ngOnInit() { 
    this.isLoading$ = this.store.let(fromRoot.getIaReportsIsLoading);
    this.presentLoading();
};

 presentLoading() {
    this.isLoading$.subscribe((currentLoading: boolean) => { 
        let loader = this.loadingCtrl.create({
            content: "Please wait while we load all Interaction Reports and Clients for you...",
        });
        console.log('currentLoading', currentLoading)
        currentLoading ? loader.present() : loader.dismiss();
    });
};

```

And that didn’t work.

I know that currentLoading is initially ‘true’ and then after loading is finished, it turns to ‘false’. And I know that the conditional is firing properly, but the loader.dismiss() is not closing the loader. Am I creating another instance unintentionally that I need to close as well?

---

<div class="post-metadata">

**Author:** ![andrewgy8](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/andrewgy8/32/106716_2.png) [@andrewgy8](https://forum.ionicframework.com/u/andrewgy8)\
**Post date:** [November 22, 2016, 4:48pm UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/2 "2016-11-22T16:48:44Z")

</div>

Anybody here with experience in Loading Controller tied to an observable boolean value?

---

<div class="post-metadata">

**Author:** ![garrykapoor](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@garrykapoor](https://forum.ionicframework.com/u/garrykapoor)\
**Post date:** [November 22, 2016, 5:08pm UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/3 "2016-11-22T17:08:41Z")

</div>

Try loader.dismissAll() instead of dismiss()

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [November 22, 2016, 5:18pm UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/4 "2016-11-22T17:18:52Z")

</div>

Why not maybe trying the “contrary” (something like following)?

```
loader.present().then(() => {
  this.isLoading$.subscribe((currentLoading: boolean) => {
      loader.dismiss();
  });
});
```

---

<div class="post-metadata">

**Author:** ![andrewgy8](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/andrewgy8/32/106716_2.png) [@andrewgy8](https://forum.ionicframework.com/u/andrewgy8)\
**Post date:** [November 22, 2016, 5:23pm UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/5 "2016-11-22T17:23:19Z")

</div>

Thanks all for the help @reedrichards and @garrykapoor! I got it working with this:

> ```
> ngOnInit() { 
> this.initLoader();
> this.isLoading$ = this.store.let(fromRoot.getIaReportsIsLoading);
> this.isLoading$.subscribe((currentLoading: boolean) => { 
> currentLoading ? this.presentLoader() : this.closeLoader()
> });
> };
> 
> ```

```
initLoader(){
    this.loader = this.loadingCtrl.create({
        content: "Please wait while we load all Interaction Reports and Clients for you...",
    });
};
presentLoader() {
    this.loader.present()
};
closeLoader(){
    this.loader.dismiss();
}

```

---

<div class="post-metadata">

**Author:** ![Kishantechwave](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@Kishantechwave](https://forum.ionicframework.com/u/Kishantechwave)\
**Post date:** [August 21, 2018, 12:27pm UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/6 "2018-08-21T12:27:18Z")

</div>

In my case the loader was dismissing even before the operation was complete.  
I need to show loader till the operation was ended, please suggest me.

Below is my code

```auto
downloadSites(SitesDetails) {
let loader = this.loadingctrl.create({
      content: 'Please wait while we load all Interaction Reports and Files for you...'
    });
 loader.present().then(() => {
 if (SitesDetails != null) {
//my code here
}
});
loader.dismiss();
}

```

---

<div class="post-metadata">

**Author:** ![Kishantechwave](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@Kishantechwave](https://forum.ionicframework.com/u/Kishantechwave)\
**Post date:** [August 24, 2018, 8:32am UTC](https://forum.ionicframework.com/t/loading-controller-dismiss/70601/7 "2018-08-24T08:32:59Z")

</div>

got this issue solved by declaring var loading=this.loading
