Injects the instance associated with the given class.
Throws an error if the class is not registered in the container.
Compared to inject, injectBy accepts a thisArg argument (the containing class) which is used to resolve circular dependencies.
injectBy
thisArg
The containing instance, used to help resolve circular dependencies.
The class to resolve.
class Wand { owner = inject(Wizard);}class Wizard { wand = injectBy(this, Wand);} Copy
class Wand { owner = inject(Wizard);}class Wizard { wand = injectBy(this, Wand);}
Injects the value associated with the given token.
Throws an error if the token is not registered in the container.
The token to resolve.
Injects the instance associated with the given class.
Throws an error if the class is not registered in the container.
Compared to inject,
injectBy
accepts athisArg
argument (the containing class) which is used to resolve circular dependencies.