@loopback/docs
Version:
Documentation for LoopBack 4
35 lines (22 loc) • 953 B
Markdown
lang: en
title: 'API docs: context.binding.toclass'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/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 | <code>Constructor<T></code> | 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`