Page Contents

Home > @loopback/context > inject > setter

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:

setter: (bindingKey: BindingAddress, metadata?: InjectBindingMetadata) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void

Parameters

Parameter Type Description
bindingKey BindingAddress The key of the value we want to set.
metadata InjectBindingMetadata (Optional) Optional metadata to help the injection

Returns:

(target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void