@loopback/docs
Version:
Documentation for LoopBack 4
46 lines (28 loc) • 1.1 kB
Markdown
lang: en
title: 'API docs: context.binding.apply'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.context.binding.apply.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/context](./context.md) > [Binding](./context.binding.md) > [apply](./context.binding.apply.md)
## Binding.apply() method
Apply one or more template functions to set up the binding with scope, tags, and other attributes as a group.
<b>Signature:</b>
```typescript
apply(...templateFns: BindingTemplate<T>[]): this;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| templateFns | <code>BindingTemplate<T>[]</code> | One or more functions to configure the binding |
<b>Returns:</b>
`this`
## Example
```ts
const serverTemplate = (binding: Binding) =>
binding.inScope(BindingScope.SINGLETON).tag('server');
const serverBinding = new Binding<RestServer>('servers.RestServer1');
serverBinding.apply(serverTemplate);
```