UNPKG

@loopback/docs

Version:

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

85 lines (43 loc) 1.84 kB
--- lang: en title: 'API docs: context.inject.setter' 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.inject.setter.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [inject](./context.inject.md) &gt; [setter](./context.inject.setter.md) ## inject.setter() function Inject a function for setting (binding) the given key to a given value. (Only static/constant values are supported, it's not possible to bind a key to a class or a provider.) This is useful e.g. when implementing Actions that are contributing new Elements. See also `Setter<T>`<!-- -->. **Signature:** ```typescript setter: (bindingKey: BindingAddress, metadata?: InjectBindingMetadata) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> bindingKey </td><td markdown="1"> [BindingAddress](./context.bindingaddress.md) </td><td markdown="1"> The key of the value we want to set. </td></tr> <tr><td markdown="1"> metadata </td><td markdown="1"> [InjectBindingMetadata](./context.injectbindingmetadata.md) </td><td markdown="1"> _(Optional)_ Optional metadata to help the injection </td></tr> </tbody></table> **Returns:** (target: Object, member: string \| undefined, methodDescriptorOrParameterIndex?: number \| TypedPropertyDescriptor&lt;any&gt; \| undefined) =&gt; void