Private
Readonly
containerPrivate
Readonly
containerPrivate
Readonly
factoriesOptional
lifecycle?: LifecyclePolicyPrivate
Readonly
instancesPrivate
Readonly
loggerPrivate
Optional
Readonly
parentPrivate
Readonly
providersPrivate
Readonly
resolvePrivate
Readonly
servicePrivate
Readonly
servicePrivate
Readonly
servicesWrap all instance created by this container in Proxies. When set to true
each service instance created by this container is wrapped in
a Proxy
For now the recommended setting is false
unless you need to dynamically swap service instances without recreated the dependencies that use them.
For circular references proxies will always be used even when useInstanceProxies is set to false
Static
rootGlobal root container; by default all services are contained in there
Returns true
if this container is the root container of the application. The root container is the container that is created
by default and contains all services by default.
Create a new instance of a type resolving constructor parameters as dependencies using the container. The returned class is not registered in the container as dependency.
Constructor/Type to instantiate
Rest
...params: PartialArray<ConstructorParameters<T>, any>Constructor params provided
New instance of an object who's dependencies are resolved by the container
Create a new instance of a type resolving constructor parameters as dependencies using the container and register it as a dependency.
Constructor/Type to instantiate
Rest
...params: PartialArray<ConstructorParameters<T>, any>Constructor params provided
Private
createCreates a new instance of the specified type resolving dependencies using the current container context. The returned class is not registered in the container as dependency.
Constructor type/prototype class definition
Private
decoratePrivate
generateSafe version of resolve that never returns undefined
and throws an Error for services that cannot be resolved.
Service type for which to resolve the concrete class
Optional
overrideLifecycle: LifecyclePolicyPrivate
getPrivate
getCreate a new container that inherits all configuration form the parent but on top of that can register or overwrite dependencies; by default dependency resolution is first attempted using the providers, factories and registered service instance in the new container; if that fails it resolution is delegated to the parent until the root container which will throw an exception in case it cannot resolve the requested module.
Optional
options: { Optional
isolated?: booleanRegister an already instantiated service/class in the container, if the instance provides one or more services which are registered using the injectable decorator then those services will be made available in the container.
Optional
options: { Optional
additionaladditional service types to register the instance for
Register an instance in the container as the specified service service shape
Instance providing the service
Service or array of service shapes provided
the instance
Register a factory that can provide an instance of the specified factory
list of services to register
factory that produces the an instance
Register a service proxy that can be manually set with a concrete instance later on. Any instance that request a service of type T will receive the proxy instance.
The proxy is not registered as a factory type.
The proxy instance can be set using the setInstance
method on the ProxyTarget returned by this method.
Service type to register
ProxyTarget instance that can be used to set the concrete instance
Registers a type in the container as provider of services; type specified is dynamically created when required injecting any resolving any dependency required
Type to register
list of services to register
Optional
serviceOptions: Partial<ServiceOptions>options including lifecycle policy of the service
Resolve requested service to an implementation.
Service type for which to resolve a concrete class
Optional
overrideLifecycle: LifecyclePolicyUse an alternate lifecycle policy
Optional
receiver: (new () => object)Class ctor for which we are resolving this
Private
trackStatic
get
Dependency injection container that can create objects marked with the injectable and automatically resolving their dependencies.
To use the container mark any class with the injectable-decorator. injectable allows specifying the lifecycle policy of the object which determines if the container will create a new instance or use the existing instance of the class registered in the container.
The container resolves all undefined constructor parameters and all properties marked with injectable.property.
Circular references are supported and handled by using a lzy resolution proxy.
Usage: