0

Say I have a class, Logger, which is not a component, which uses ServiceA (marked as Injectable). Logger's constructor look like:

Logger(this._logger);

Will AngularDart implicitly pass ServiceA to Logger upon instantiation even though Logger is not a component or directive? The AngularDart docs are unclear on this.

Nodeocrat
  • 816
  • 2
  • 14
  • 29

1 Answers1

0

When Logger is instantiated by DI (AngularDart) it will try to resolve all dependencies (constructor arguments, also transitive) and pass them to the constructor or throw otherwise.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Thanks for the answer, do you know if the same would true for the current scope? If scope is used in some class which isn't a component or directive, would DI try to resolve that too? – Nodeocrat Dec 16 '15 at 10:49
  • Not sure what you mean by "current scope". I don't think there's are exceptions. If you request an instance from DI (or Angular does implicitly) it tries to resolve constructor arguments. Can you provide a concrete code example to demonstrate what you mean? – Günter Zöchbauer Dec 16 '15 at 15:28