UNPKG

@loopback/docs

Version:

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

52 lines (33 loc) 1.49 kB
--- lang: en title: 'API docs: context.binding.tag' 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.binding.tag.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Binding](./context.binding.md) &gt; [tag](./context.binding.tag.md) ## 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. <b>Signature:</b> ```typescript tag(...tags: BindingTag[]): this; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | tags | [BindingTag](./context.bindingtag.md)<!-- -->\[\] | 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 | <b>Returns:</b> this ## Example ```ts // 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'}); ```