Activity Indicator is not shown


#1

I’m struggling with an issue preventing Activity Indicator being shown in my Angular-Nativescript Project.
I have a method deleteData (see below) executing a long-running task: I need to display “Activity Indicator” at the start and at the end of the method.

The activity Indicator is not displayed, maybe because Angular doesn’t refresh the UI during method execution - I tried to use also Promise and Observable but I had the same result - any idea how to solve?

public deleteData() {
var loader = new LoadingIndicator();
loader.show();
// long running task
this.database.executeQuery(“all_customers”);
loader.hide();
}


#2

I don’t think that plugin supports Angular (yet not sure). I use something similar to this in my Angular app.


#3

First of all, thanks for your suggestion.

I tried your sample without changes and it worked - but if I move the logic/code from NgInit to a method (see below sample), it doesn’t work anymore.

My requirement is to have a button to execute a long-running task - so, I need a specific method with the logic to display the loader, execute the task and hide the loader.

Any idea on the issue with below implementation?


public deleteData() {
uiHelper.showLoader();
// Long running task
setTimeout(uiHelper.hideLoader, 2000);
}


#4

It should work. If you are able to reproduce the issue in the play example, please do so and share so I can dig further.


#5

You’re right - it works.

Also LoadingIndicator plug-in works now :slightly_smiling_face:
The secret is to place inside the method the “setTimeout” call: this one forces UI refresh

Thanks again for suggestion


           loader.show(options);
            setTimeout(() => {
                // Long running task
                this.database.executeQuery("all_customers");
                loader.hide();
            }, 100);