Dependency Injection, nested providers


#1

I’m building this app (ionic beta6, typescript) and I ran into this strange (to me) situation.

I’ve got two providers. One is named DatabaseStorage (handles database calls) and one 1 named MyData (which calls a rest API). The DatabaseStorage provider is only needed by the MyData provider. The MyData provider gets the DBStorage provider through DI.

The page calls the MyData Provider (Through DI), but that only works when I also do an import for the DatabaseStorage provider on the page. Otherwise, the databasestorageprovider is not included in the MyData Service.

Isn’t this strange, or is this intended? Because the MyData provider’s got his own dependency on the DatabaseStorage provider. So why should the Page have this import?


#2

AFAIK the short answer is (check out the related topic for more details and resources):


#3

Thanks for your reply. Strange choice if you ask me…