UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

76 lines (41 loc) 1.4 kB
--- lang: en title: 'API docs: context.binding.apply' 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.apply.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Binding](./context.binding.md) &gt; [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. **Signature:** ```typescript apply(...templateFns: BindingTemplate<T>[]): this; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> templateFns </td><td markdown="1"> [BindingTemplate](./context.bindingtemplate.md)<!-- -->&lt;T&gt;\[\] </td><td markdown="1"> One or more functions to configure the binding </td></tr> </tbody></table> **Returns:** this ## Example ```ts const serverTemplate = (binding: Binding) => binding.inScope(BindingScope.SINGLETON).tag('server'); const serverBinding = new Binding<RestServer>('servers.RestServer1'); serverBinding.apply(serverTemplate); ```