Page Contents
Home > @loopback/context > Binding > tag
Binding.tag() method
Tag the binding with names or name/value objects. A tag has a name and an optional value. If not supplied, the tag name is used as the value.
Signature:
tag(...tags: BindingTag[]): this;
Parameters
Parameter | Type | Description |
---|---|---|
tags | BindingTag[] | A list of names or name/value objects. Each parameter can be in one of the following forms: - string: A tag name without value - string[]: An array of tag names - TagMap: A map of tag name/value pairs |
Returns:
this
Example
// Add a named tag `controller`
binding.tag('controller');
// Add two named tags: `controller` and `rest`
binding.tag('controller', 'rest');
// Add two tags
// - `controller` (name = 'controller')
// `{name: 'my-controller'}` (name = 'name', value = 'my-controller')
binding.tag('controller', {name: 'my-controller'});