@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
77 lines (43 loc) • 1.33 kB
Markdown
---
lang: en
title: 'API docs: context.binding.toprovider'
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.toprovider.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/context](./context.md) > [Binding](./context.binding.md) > [toProvider](./context.binding.toprovider.md)
## Binding.toProvider() method
Bind the key to a value computed by a Provider.
\*
**Signature:**
```typescript
toProvider(providerClass: Constructor<Provider<T>>): this;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
providerClass
</td><td markdown="1">
[Constructor](./context.constructor.md)<!-- --><[Provider](./context.provider.md)<!-- --><T>>
</td><td markdown="1">
</td></tr>
</tbody></table>
**Returns:**
this
## Example
```ts
export class DateProvider implements Provider<Date> {
constructor(@inject('stringDate') private param: String){}
value(): Date {
return new Date(param);
}
}
```