0

I have an angular app with javascript code I can't touch (3rd party code).

I'd like to intercept the http messages from outside of angular. I have figured out how to get the controller and injector and can get the $http service, but I can't seem to get the $httpProvider so I can add an intercept something like here

Code I've got so far is (it's actually in a timeout but I left that out for brevity),

 $(window).load(
      ...
      var injector = angular.element('#myBody').injector();
      var httpProvider = injector.get('$httpProvider ');
      httpProvider.interceptors.push(function ($q) {
         ...

but httpProvider isn't defined, $http is defined but it's not the same as the provider - I'm fairly new to angular, so is there any way to get the provider? Version is 1.1.5

Community
  • 1
  • 1
daven11
  • 2,905
  • 3
  • 26
  • 43

1 Answers1

0

Just to close the question - as calebboyd said:

Perhaps you can extend the app.

angular.module("3rdPartyApp").config(function($httpProvider){...});

This works.

Community
  • 1
  • 1
daven11
  • 2,905
  • 3
  • 26
  • 43