Skip to content

injector

@tsed/di

Usage

typescript
import { injector } from "@tsed/di";

See /packages/di/src/common/fn/injector.ts.

Overview

ts
function injector(): InjectorService;

Description

Get the global injector service instance.

Returns the singleton instance of InjectorService managing all registered providers. Use this to access the DI container programmatically.

Usage

typescript
import {injector, Injectable} from "@tsed/di";

@Injectable()
class MyService {
  injector = injector();

  getService() {
    return injector().get(OtherService);
  }
}

Released under the MIT License.