Page Contents

Home > @loopback/context > inject > tag

inject.tag() function

Inject an array of values by a tag pattern string or regexp

Signature:

tag: (bindingTag: BindingTag | RegExp, metadata?: InjectionMetadata) => (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void

Parameters

Parameter Type Description
bindingTag [BindingTag](/doc/en/lb4/apidocs.context.bindingtag.html) \| RegExp Tag name, regex or object
metadata [InjectionMetadata](/doc/en/lb4/apidocs.context.injectionmetadata.html) _(Optional)_ Optional metadata to help the injection

Returns:

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

Example

class AuthenticationManager {
  constructor(
    @inject.tag('authentication.strategy') public strategies: Strategy[],
  ) {}
}