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 | RegExp Tag name, regex or object
metadata InjectionMetadata (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[],
  ) {}
}