0

I'm wondering if it possible to include a .config section just once and that it affects all modules. Question is related with caching requests in IE, and since I don't want to do this in every module that is making requests, I was wondering if it possible to include a .config section globally...

I've googled quite a lot, look in the Angular tutorial, looked at the NG-book and found nothing on this regard...any idea?

Thanks!

EDIT: Just added this as a config in the module included in all controllers and it works

Community
  • 1
  • 1
AlejandroVK
  • 7,373
  • 13
  • 54
  • 77
  • Have you tested to just configuring httpProvider in your main module? It should be enough. – tasseKATT May 09 '14 at 21:14
  • Hello tasseKATT, nope I haven't...do you mean that there is some sort of inheritance between modules? I know that works like that with scopes, but not sure about config... – AlejandroVK May 10 '14 at 07:53
  • All used modules are combined into a single app. There is only one injector per app, which is why services from all modules are available. This means there should for example only be one httpProvider as well. – tasseKATT May 10 '14 at 08:13
  • Makes sense, I'll try it out and see what happens, thanks! – AlejandroVK May 10 '14 at 11:08
  • No problem :) Let me know how it turns out. – tasseKATT May 10 '14 at 11:12
  • tasseKATT, I've modified this as suggested and it works, if you want to publish an answer I'll mark it as the right answer. – AlejandroVK May 12 '14 at 14:11

1 Answers1

1

During bootstrap all modules are combined into one application and a single injector is created for it. Services in Angular are singletons in the sense that they are only created once per injector.

This means that there is only once $http service created and its configuration will be global for the entire application.

tasseKATT
  • 38,470
  • 8
  • 84
  • 65