Documentation / @zerotal/core / index / inject
Function: inject()
inject(...
tokens): (target,_context) =>void
Defined in: container/inject.ts:44
Mark a class for auto-wiring by the container, declaring its constructor
dependencies in order. @inject() with no tokens marks a class with a
no-argument constructor for auto-wiring.
Parameters
tokens
...BindingToken[]
Returns
(target, _context) => void
Example
@inject(Db, Cache)
class UserService {
constructor(private db: SQL, private cache: CacheManager) {}
}
// The container builds the dependencies and injects them in order:
const users = await container.make(UserService);