AFAIK you do need to use the $injector service, but only ask for $http when 
the interceptor is called (i.e. in your callback function), so in your 
example:

factory("interceptor", function ($q, $location, $injector) {
    var $http;
    return function (promise) {
        $http = $http || $injector.get('$http'); // do it here instead
        // do something with $http here...
        return promise;
    }
}

I've used this approach before when depending on services in my 
interceptors that depend on $http, seems to do the trick.

On Wednesday, 15 January 2014 05:39:54 UTC+13, Evgeni T wrote:
>
> The idea is to get a data from another source in certain cases, so I have 
> this:
>
> factory("interceptor", function ($q, $location, $http) {
>>     return function (promise) {
>>         return promise;
>>     }
>> }
>
>
> which fails with* [$injector:cdep] Circular dependency found: interceptor 
> <- $http*
>
> Also tried to inject $injector and retrieve $http using that, with same 
> results. Any ideas?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to