@loopback/docs
Version:
Documentation for LoopBack 4
34 lines (21 loc) • 871 B
Markdown
lang: en
title: 'API docs: context.binding.toclass'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
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`