Page Contents

Home > @loopback/context > Binding > toClass

Binding.toClass() method

Bind the key to an instance of the given class.

Signature:

toClass<C extends T & object>(ctor: Constructor<C>): this;

Parameters

Parameter Type Description
ctor [Constructor](/doc/en/lb4/apidocs.context.constructor.html)<C> The class constructor to call. Any constructor arguments must be annotated with `@inject` so that we can resolve them from the context.

Returns:

this