---
lang: en
title: 'API docs: context.createbindingfromclass'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.context.createbindingfromclass.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [createBindingFromClass](./context.createbindingfromclass.md)

## createBindingFromClass() function

Create a binding from a class with decorated metadata. The class is attached to the binding as follows: - `binding.toClass(cls)`<!-- -->: if `cls` is a plain class such as `MyController` - `binding.toProvider(cls)`<!-- -->: it `cls` is a value provider class with a prototype method `value()`

<b>Signature:</b>

```typescript
export declare function createBindingFromClass<T = unknown>(cls: Constructor<T | Provider<T>>, options?: BindingFromClassOptions): Binding<T>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  cls | <code>Constructor&lt;T &#124; Provider&lt;T&gt;&gt;</code> | A class. It can be either a plain class or a value provider class |
|  options | <code>BindingFromClassOptions</code> | Options to customize the binding key |

<b>Returns:</b>

`Binding<T>`


