0

I have been looking at the angular docs for this as well as other stackoverflow posts. I want to initialize/configure a service from a library that will be injected into components for an app. More specifically I have an http service that exists in a library. I want this library to know what environment the application is in. However in accordance with the angular docs this library is stateless which means the environment variable needs to be provided to the library. My temptation was to do this with DI however you can't use DI within a library that injects a service from the application (outside of the library). Furthermore you can't use a hybrid approach for a constructor that relies on DI for some dependencies but non-DI for other dependencies. This brings me to my question. For a library that needs to know about the environment of the application for the sake of initializing services that are using DI, what is the correct way to initialize these services with this environment variable?

slipperypete
  • 5,358
  • 17
  • 59
  • 99
  • Not sure if it Helps , Please check - https://blog.clairvoyantsoft.com/assets-support-for-angular-7-library-b3ceb0c7484b and https://octoperf.com/blog/2019/08/22/kraken-angular-workspace-multi-application-project/#sharing-assets-across-libraries-and-applications – abhay tripathi Aug 04 '20 at 18:08
  • Thanks ... I actually ended up finding an answer here ... I guess I was asking the more confusing version of the question. Thanks. https://stackoverflow.com/questions/43529920/passing-environment-variables-to-angular2-library – slipperypete Aug 04 '20 at 19:55

0 Answers0