Tips for identifying the load window in Ionic 2 RC3 Angular 2

In the various services that I am using, I implement a method to load content. Each service has its own loadController to display a loading window. How can I detect if a loading window already exists in order to prevent showing a new one?

*Please note: I need to detect this in the service, not in the component.

Answer №1

Check out this snippet of code that I've been using for a different purpose, but thought it might be helpful:

import { Nav, Platform, IonicApp, ... } from 'ionic-angular';

@Component({
    selector: 'page-custom',
    templateUrl: 'custom.html'
})
export class CustomPage {

    constructor(private platform: Platform,
                private ionicApp: IonicApp) { 

         // ...
    }

    public displayNewModalByClosingCurrentOne(): void {

        let activePortal = this.ionicApp._loadingPortal.getActive() ||
            this.ionicApp._modalPortal.getActive() ||
            this.ionicApp._toastPortal.getActive() ||
            this.ionicApp._overlayPortal.getActive();

        if (activePortal) {

            // Dismiss the currently active portal
            activePortal.dismiss();
            activePortal.onDidDismiss(() => { 

                // Add logic to show the new modal here...

            });
            return;
        }
    }

    // Alternatively, you can utilize the `activePortal` property to prevent 
    // displaying another loading screen before closing the current one.
    public displayNewModal(): void {

        let activePortal = this.ionicApp._loadingPortal.getActive() ||
            this.ionicApp._modalPortal.getActive() ||
            this.ionicApp._toastPortal.getActive() ||
            this.ionicApp._overlayPortal.getActive();

        if (!activePortal) {

            // Show your new modal here
        }
    }

}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changing the positions of objects on a resized HTML Canvas

I am currently developing a tool that allows users to draw bounding boxes on images using the Canvas and Angular. Everything was working smoothly until I encountered an issue with zooming in on the canvas causing complications when trying to draw bounding ...

Webpack bundling only a singular Typescript file rather than all of its dependencies

I'm currently facing a challenge while attempting to consolidate all the files in my Typescript project, along with their dependencies from node_modules, into a single file using Webpack. Despite trying multiple options, it seems that only the entry f ...

Is it possible that the installation issue with 'File' from ionic-native is due to dependencies?

As a newcomer to Ionic2, I'm facing some beginner obstacles. Despite my extensive search efforts, I haven't been able to find any examples related to my issue. My current goal is to write a file to a specific directory on the device using Ionic2 ...

The alignment of the toolbar in angular material is fixed and cannot

I have been attempting to center an icon within a material toolbar, but it seems to be offset slightly to the right due to a second image on the left side. Here is my code: <mat-toolbar color="primary"> <mat-toolbar-row> <span> < ...

Exploring the difference between loop and stream patterns in Azure Service Bus message receiving operations

I am currently setting up the Azure Service Bus messaging infrastructure for my team, and I am working on establishing best practices for developing Service Bus message receivers. We are in the process of creating a new service to consume the Service Bus m ...

"In the realm of RxJS, there are two potent events that hold the power to

In my current situation, I encountered the following scenario: I have a service that makes Http calls to an API and requires access to user data to set the authentication header. Below is the function that returns the observable used in the template: get ...

What is the rationale behind assigning a random value to the `(keyup)` event in order to update template local variables in Angular2?

To update #box in <p>, I need to give a random value to the (keyup) attribute. Here's an example: <!-- The value on the right of equality sign for (keyup) doesn't matter --> <input #box (keyup)="some_random_value" placeholder ...

Utilize the failure of Travis due to issues with a Git submodule to improve

I am facing an issue with my Angular project that has a git submodule for the backend. When I build the project on my local machine, it is successful. However, when I try to build it on Travis, it fails. npm ERR! enoent ENOENT: no such file or directory, ...

Exploring the World of Micro-Frontends with the Angular Framework

I am conducting research on the best methods for transitioning a large single-page application into a micro-frontend architecture. The concept: The page is made up of multiple components that function independently Each component is overseen by its own ...

The function 'ChartModule' cannot be called, as function calls are not supported

I am encountering a similar problem as discussed in Angular 2 - AOT - Calling function 'ChartModule', function calls not supported ERROR: Error encountered while resolving symbol values statically. Trying to call function 'ChartModule&apos ...

Can you guide me on utilizing the drag and drop functionality in Angular 8 CDK to merge two cards together?

My current challenge involves attempting to drag one card over another card in order to effectively "merge" or "combine" them, similar to the action of dragging an image onto a folder on a desktop. Despite utilizing HTML5 native drag and drop functionalit ...

What is the best way to save objects in the store (ngrx, ngxs) while preserving their methods functionality?

As I delve into the Redux pattern, I realize the importance of storing only plain objects in the Store. However, I find myself wanting to use more complex objects with methods like "hasParent", "isReadonly", and "isValid" in my application. While ngrx all ...

Angular Module without any components

The Angular modules documentation provides an example of a module that includes a template, a component, and a provider. This module is then imported into the root module and instantiated by using the element defined by the component like this: <app-co ...

Adding dropdowns to divs in Angular applications

Currently, I am attempting to integrate a dropdown feature into a div element. The HTML code for the dropdown is generated dynamically within the code. When clicking on the dropdown button, it appears functional but unfortunately, the dropdown itself does ...

Determine the dynamic height of content in a TypeScript file

Could you please provide guidance on obtaining the height of the content within this particular div element? For example, I need to calculate the dynamic height of the content. code .html <div class="margin-top-47 margin-horizontal-10" #hel ...

Angular component experiencing issues with implementing Bootstrap styles

I followed a tutorial to apply the bootstrap 5.3.0 style to my navigation bar, but the outcome looks different from what was shown in the tutorial. This is the HTML code for the navigation component: <nav class="navbar navbar-default"> & ...

Angular's AsyncValidatorFn is triggered by the onblur event and does not work with keypress events

I'm currently working with the latest version of Angular and I'm attempting to implement a custom validation for checking a code through a RestAPI. The example below is functional, but it doesn't trigger on keypress events; it only activates ...

Exploring code coverage for the sortmethod in Angular applications

Within my project, I have a file named sorting.helper.ts that contains all of my sorting methods: In another file, I then called upon these methods. How can I ensure that both files are included in the code coverage analysis for my .spec file? import { C ...

Enabling universal pre-rendering results in the establishment of empty transfer-state

I have implemented Angular Universal in my application along with prerendering. The specific paths that I have set for prerendering are as follows: / /about /login Interestingly, the only path that utilizes transfer state is: /:id Upon building and run ...

Tips for replacing HTTP response in Angular 4

One of my challenges involves using a specialized HttpService that inherits from Angular's native Http: export class HttpService extends Http { } I am trying to figure out how to intercept/override the response: My attempt to do this looks like: r ...