LoadingController dismissing twice

Hello All,

I’m working with LoadingController Ionic.

What is required is just to check the loader is currently running?
I only want to dismiss it if its spinning, else I wont be calling the loader.dismiss();

I’m handling the loader in a unique way thats why I need to check if its already dismissed or not?

How to get this, I’ve tried onDidDismiss but thats a callback and not going to work in my case.

I hope the audience got my point.



not really. Maybe you should describe it better with code.

Otherwise, instead checking the loader itself, check/unckeck a flag that you set where/when ever you want.

Best regards, anna-liebt

“Unique” is generally something I try to avoid. Idiomatic and conventional designs, while they may seem boring, cause many fewer problems.

You could be checking for the var that you assigned your Loading Controller to. See the snippet below. It was more to prevent loading controllers from stacking but I think you can find a hint in there:

import { Injectable } from '@angular/core';
import { LoadingController } from 'ionic-angular';

export class LoadingProvider {

    public loading = null;

    constructor (
        private loadingCtrl: LoadingController
    ) {

    presentLoader() {
        // this below will prevent "stacking" as long as we treat this.loading as a single source of truth for any loader:
        if (this.loading) {
            this.loading = null;
        // the rest is as usual
        this.loading = this.loadingCtrl.create({
            content: 'Please wait...'
        setTimeout(() => {
        }, 5000);
1 Like