UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

65 lines (34 loc) 1.18 kB
--- lang: en title: 'API docs: context.binding.toclass' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context permalink: /doc/en/lb4/apidocs.context.binding.toclass.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Binding](./context.binding.md) &gt; [toClass](./context.binding.toclass.md) ## Binding.toClass() method Bind the key to an instance of the given class. **Signature:** ```typescript toClass<C extends T & object>(ctor: Constructor<C>): this; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> ctor </td><td markdown="1"> [Constructor](./context.constructor.md)<!-- -->&lt;C&gt; </td><td markdown="1"> The class constructor to call. Any constructor arguments must be annotated with `@inject` so that we can resolve them from the context. </td></tr> </tbody></table> **Returns:** this