Error with LoadingController

I have a method in my service with this code:

this.loading.present();, JSON.stringify(requestBody), {headers: headers})
 .then(response => {
    this.auth.authLogin(type, userInfo.usuario, response.json().token);
 .catch(response => {

The first time that my executed this.loading.dismiss(); everything works ok, but if i try again the console returns the error:

Cannot ready property ‘nativeElement’ of null

Some help?

Don’t reuse loading components. Create a new one each time.

Didnt understand. I’m not reusing LoadingController. I import in my service and i need to show and hide with present() and dismiss().

How can i did this ?

The fact that you’re referencing the loading indicator component (not the controller) as this.loading leads me to suspect that you’re calling create only once, stashing the result in an object property, and then attempting to present/dismiss it over and over. That won’t work. It can be only used once, so I recommend never storing it as an object property, only in lexically scoped variables. That way you can be sure you don’t try to reuse them.


I was creating loadingController with a variable in the begin of my service and after in my method executing present() and dismiss().

Now i add the .create before the present() into my method and works well. Thank you bro!