erfling
erfling

Reputation: 409

Any way to inject a provider with a dependency on another provider in AngularJS config

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?

Upvotes: 0

Views: 50

Answers (0)

Related Questions