Variable Injector

Injector: Type<Injector>

Injector token for dynamic injection.

class Wizard {
private injector = inject(Injector);
private wand?: Wand;

getWand() {
return (this.wand ??= this.injector.inject(Wand));
}
}

const wizard = container.resolve(Wizard);
wizard.getWand(); // => Wand