Uncaught Error: [$injector:unpr] Unknown provider: dependency1Provider <- dependency1 <- $http <- $compile

StackOverflow https://stackoverflow.com/questions/23665246

  •  22-07-2023
  •  | 
  •  

Question

After copying some example code form angularjs' website I've received the following error:

Uncaught Error: [$injector:unpr] Unknown provider: dependency1Provider <- dependency1 <- $http <- $compile

This was after I've failed to get the $httpProvider because it has to be used in the configuration stage on angularjs (before everything else, in config(..)).

Was it helpful?

Solution

This is the damned code I copied without much thinking:

$httpProvider.interceptors.push(function($q, dependency1, dependency2) {
    return {
     'request': function(config) {
         // same as above
      },

      'response': function(response) {
         // same as above
      }
    };
  });

The problem (obviously) was that the function inside the push had 2 example parameters - "dependency1, dependency2", after removing them everything was working again.

Hope this could help someone as tired as me trying to search for that error message instead of reading it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top