# ionicLoading not working

**URL:** <https://forum.ionicframework.com/t/ionicloading-not-working/8742>\
**Category:** uncategorized\
**Created:** [August 25, 2014, 4:23pm UTC](https://forum.ionicframework.com/t/ionicloading-not-working/8742 "2014-08-25T16:23:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkbart](https://avatars.discourse-cdn.com/v4/letter/f/ba9def/32.png) [@fkbart](https://forum.ionicframework.com/u/fkbart)\
**Post date:** [August 25, 2014, 4:23pm UTC](https://forum.ionicframework.com/t/ionicloading-not-working/8742/1 "2014-08-25T16:23:11Z")

</div>

Any Idea what could be wrong ?

```
[$injector:unpr] Unknown provider: $ionicLoading
http://errors.angularjs.org/1.2.22/$injector/unpr?p0=%24ionicLoading
http://192.168.1.106:8100/lib/angular/angular.js:3792:86
getService@http://192.168.1.106:8100/lib/angular/angular.js:3920:46
invoke@http://192.168.1.106:8100/lib/angular/angular.js:3947:23
http://192.168.1.106:8100/lib/angular/angular.js:3875:42
forEach@http://192.168.1.106:8100/lib/angular/angular.js:325:22

var intercept = angular.module('services.interceptor', [
   'ionic'
]);

intercept.config(function ($httpProvider, $ionicLoading) {

    $httpProvider.interceptors.push(function ($q, $ionicLoading) {
        return {
            responseError: function (rejection) {
                if (rejection.status == 0) {
                    $ionicLoading.show(
                        {
                            template: "Unable to process request. Probably connection is down.",
                            duration:3000
                        }
                    );
                }
                return $q.reject(rejection);
            }
        };
    });
});
```

---

<div class="post-metadata">

**Author:** ![fkbart](https://avatars.discourse-cdn.com/v4/letter/f/ba9def/32.png) [@fkbart](https://forum.ionicframework.com/u/fkbart)\
**Post date:** [August 25, 2014, 8:58pm UTC](https://forum.ionicframework.com/t/ionicloading-not-working/8742/2 "2014-08-25T20:58:26Z")

</div>

one findings, that it does work when injected inside controller and run method but not in the config.

So it looks like the only way to sort this out if I want to still utilize this ionicLoader on global level is to  
have interceptor only broadcast a event lets say.: _app.network.error,_ msg and in the RUN listen on this and there show a $ionicLoading

-Fk

---

<div class="post-metadata">

**Author:** ![Auro](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Auro](https://forum.ionicframework.com/u/Auro)\
**Post date:** [August 26, 2014, 12:11pm UTC](https://forum.ionicframework.com/t/ionicloading-not-working/8742/3 "2014-08-26T12:11:01Z")

</div>

the problem is in config you can only use providers and not factories/controllers etc.  
I would try using the $injector, or as you said with broadcast.

there is a similar post here:

> **[TemplateURL for ionicLoading when used with global interceptors](http://forum.ionicframework.com/t/templateurl-for-ionicloading-when-used-with-global-interceptors/8714?u=auro)**
>
> Hello can anyone suggest me how to use $ionicLoading when used with global HTTP interceptors? myApp.config(\['$httpProvider', '$stateProvider', '$urlRouterProvider', function($httpProvider, $stateProvider, $urlRouterProvider) { ...

  
here an other ressource:  

> **[Using Response Interceptors to Show and Hide a Loading Widget](http://codingsmackdown.tv/blog/2013/01/02/using-response-interceptors-to-show-and-hide-a-loading-widget/)**
>
> AngularJS provides extension points which allow you to intercept responses to http requests before they are handed over to the application code. You can use these extension points to provide global…

---

<div class="post-metadata">

**Author:** ![fkbart](https://avatars.discourse-cdn.com/v4/letter/f/ba9def/32.png) [@fkbart](https://forum.ionicframework.com/u/fkbart)\
**Post date:** [August 26, 2014, 6:00pm UTC](https://forum.ionicframework.com/t/ionicloading-not-working/8742/4 "2014-08-26T18:00:49Z")

</div>

Cool. Yepa I figured that i can call $injector from this post but at the end I liked this broadcast thing’-)
