# $ionicLoading, is there a way to cancel loading?

**URL:** <https://forum.ionicframework.com/t/ionicloading-is-there-a-way-to-cancel-loading/2939>\
**Category:** ionic-v1\
**Created:** [April 13, 2014, 10:14am UTC](https://forum.ionicframework.com/t/ionicloading-is-there-a-way-to-cancel-loading/2939 "2014-04-13T10:14:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![manol](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@manol](https://forum.ionicframework.com/u/manol)\
**Post date:** [April 13, 2014, 10:14am UTC](https://forum.ionicframework.com/t/ionicloading-is-there-a-way-to-cancel-loading/2939/1 "2014-04-13T10:14:58Z")

</div>

Hello Guys.

```
Is it possible to cancel the loading spinner by the user when it is taking a long time, like a cancel button or just touching the screen?

```

Thank you.

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [April 13, 2014, 3:06pm UTC](https://forum.ionicframework.com/t/ionicloading-is-there-a-way-to-cancel-loading/2939/2 "2014-04-13T15:06:12Z")

</div>

I don’t think so. Here is the key :

> An overlay that can be used to indicate activity while _ **blocking** _ user interaction.

I personally kill the loading indicator after a pre-defined time. I’ve decided that on mobile, after 2.5 seconds to tell the user the request failed. However, as the loading indicator is blocking (z-index), the user can’t do anything on the screen.

---

<div class="post-metadata">

**Author:** ![MrOnosa](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@MrOnosa](https://forum.ionicframework.com/u/MrOnosa)\
**Post date:** [August 14, 2014, 8:53pm UTC](https://forum.ionicframework.com/t/ionicloading-is-there-a-way-to-cancel-loading/2939/3 "2014-08-14T20:53:07Z")

</div>

I solved this issue by creating a cancel button and using the $rootScope to handle it. This isn’t a good solution, but it works.

```
$rootScope.cancel = $ionicLoading.hide; //Or whatever action you want to preform

$ionicLoading.show({ template: '<button class="button button-clear" style="line-height: normal; min-height: 0; min-width: 0;" ng-click="$root.cancel()"><i class="ion-close-circled"></i></button> Loading...' });
```

---

<div class="post-metadata">

**Author:** ![maskie](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@maskie](https://forum.ionicframework.com/u/maskie)\
**Post date:** [July 15, 2015, 8:23am UTC](https://forum.ionicframework.com/t/ionicloading-is-there-a-way-to-cancel-loading/2939/4 "2015-07-15T08:23:59Z")

</div>

Thanks. I am not since which ionic version, but now you can put the cancel into the scope of the controller.

```
$scope.cancel = $ionicLoading.hide; //Or whatever action you want to preform

$ionicLoading.show({ template: '<button class="button button-clear" style="line-height: normal; min-height: 0; min-width: 0;" ng-click="$root.cancel()"><i class="ion-close-circled"></i></button> Loading...' , scope: $scope});
```
