# Container Class

Module
import { Container } from "@tsed/di"
Source/packages/di/src/class/Container.ts

# Overview

class Container extends LocalsContainer<Provider<any>> {
    add(token: TokenProvider, settings?: Partial<IProvider<any>>): this;
    addProvider(token: TokenProvider, settings?: Partial<IProvider<any>>): this;
    hasProvider(token: TokenProvider): boolean;
    setProvider(token: TokenProvider, provider: Provider<any>): this;
    getProvider(token: TokenProvider): Provider<any> | undefined;
    getProviders(type?: ProviderType | string): Provider<any>[];
    addProviders(container: Map<TokenProvider, Provider<any>>): void;
}

# Members

add(token: TokenProvider, settings?: Partial<IProvider<any>>): this

addProvider(token: TokenProvider, settings?: Partial<IProvider<any>>): this

Add a provider to the


hasProvider(token: TokenProvider): boolean

setProvider(token: TokenProvider, provider: Provider<any>): this

Add a provider to the


getProvider(token: TokenProvider): Provider<any> | undefined

The getProvider() method returns a specified element from a Map object.


getProviders(type?: ProviderType | string): Provider<any>[]
Param Type Description
type ProviderType Optional. Filter the list by the given ProviderType.

Get all providers registered in the injector container.


addProviders(container: Map<TokenProvider, Provider<any>>): void