@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
35 lines (22 loc) • 1 kB
Markdown
---
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) > [@loopback/context](./context.md) > [Binding](./context.binding.md) > [toClass](./context.binding.toclass.md)
## Binding.toClass() method
Bind the key to an instance of the given class.
<b>Signature:</b>
```typescript
toClass(ctor: Constructor<T>): this;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| ctor | [Constructor](./context.constructor.md)<!-- --><T> | The class constructor to call. Any constructor arguments must be annotated with <code>@inject</code> so that we can resolve them from the context. |
<b>Returns:</b>
this