1

I have a function that returns Provider[]. I use it to apply some predefined providers to a component. While writing tests for that function, I realized that Injector.create will not accept Provider[], but StaticProvider[]. Now, I see that difference in interface, but I don't understand difference in behavior. If I change my function to return StaticProvider[](that requires change from Type to ConstructorProvider), nothing really change and all of my tests are passing. Same happens if I cast return value to StaticProvider[] for injector.

So I was wondering, what is actual change in behavior between the two, If it doesn't matter which one I use for my use case.

docs links:

https://angular.io/api/core/Provider

https://angular.io/api/core/StaticProvider

Eggy
  • 4,052
  • 7
  • 23
  • 39
  • 1
    Please check [this](https://stackoverflow.com/questions/48594944/can-deps-also-be-used-with-useclass/48595518#48595518) answer – Siddhant Jan 03 '22 at 17:38
  • @Siddhant Hey, thanks for a link, it will be very helpful. – Eggy Jan 04 '22 at 19:16

0 Answers0