Allows performing injections outside the normal injection context window.
Example:
classWizard { privateinjector = inject(Injector);
// Lazily initialize the wand property privatewand?: Wand;
getWand(): Wand { // An injection context does not exist here, but the // Injector instance retains and reuses the context // that was present at the time of its injection return (this.wand ??= this.injector.inject(Wand)); } }
Allows performing injections outside the normal injection context window.
Example: