0

Given the code:

angular
  .module('someApp', ['provider1Module, provider2Module'])
  .config(function (provider1ModuleProvider, provider2ModuleProvider){
     provider1ModuleProvider.getSomethingSpecific()
  })

Given also that provider1ModuleProvider.getSomethingSpecific() depends on a method of provider2ModuleProvider's getSomethingGeneric() method, how can I call this method from within the config?

Right now, when I try to run code similar to this, I get an error that essentially tells me the second provider is not instantiated. Can I explicitly instantiate both providers in the config in some way so that one provider's dependency on the other is resolved?

Essentially, what I'm trying to do is get some data in an abstract view state for some views in UI-router so that I can use it in child views. If my pattern above won't work, any other suggestions?

Cœur
  • 37,241
  • 25
  • 195
  • 267
erfling
  • 384
  • 2
  • 16
  • How does `provider1ModuleProvider.getSomethingSpecific()` depend on `provider2ModuleProvider`? Is `provider1ModuleProvider` trying to inject `provider2ModuleProvider` internally? Can you show more code of how the dependency is set up? – tasseKATT Feb 08 '15 at 15:59
  • That is correct. provider1ModuleProvider is trying to inject provider2ModuleProvider internally, but of course it is undefined in the config phase. I'm starting to think it just isn't possible. If it were possible to set up ui-router states in the run phase, I would have no issue. – erfling Feb 08 '15 at 16:19
  • Could you do something like this? http://plnkr.co/edit/DAzdvgBnRtCH8gTFdpm7?p=preview – tasseKATT Feb 08 '15 at 16:23

0 Answers0