# ★ Attribute() constructor

## `Attribute()`

Creates a new [`Attribute`](/attribute/attribute.md) instance with the **name** and **value**.

{% code title="attribute.class.ts" %}

```typescript
constructor(name: Name, value: Value) {
  super(Attribute.template`${name}${value}`);
  this.#name = String(name) as Name;
  this.#value = String(value) as Value;
}
```

{% endcode %}

### Parameters

<table><thead><tr><th width="173.44477578337126">Name: type</th><th>Description</th></tr></thead><tbody><tr><td><code>name: Name</code></td><td>The attribute name of a generic type variable <code>Name</code>.</td></tr><tr><td><code>value: Value</code></td><td>The attribute value of a generic type variable <code>Value</code>.</td></tr></tbody></table>

### Returns

The **return value** is a new [`Attribute`](/attribute/attribute.md) instance with the primitive value of the provided `name` and `value` on the template `${Name}="${Value}"`.

### Example usage

```typescript
// Example usage.
import { Attribute } from '@angular-package/tag';

// Returns Attribute {'color="red"'} of type Attribute<"color", "red">.
new Attribute('color', 'red');
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tag.angular-package.dev/attribute/attribute-constructor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
