Attribute: AttributeFactory

export Attribute : AttributeFactory

exported from angular2/core defined in angular2/src/core/metadata.ts (line 941)

Specifies that a constant attribute value should be injected.

The directive can inject constant string literals of host element attributes.

Example

Suppose we have an <input> element and want to know its type.

<input type="text">

A decorator can inject string literal text like so:

@Directive({selector: 'input'}) class InputAttrDirective { constructor(@Attribute('type') type) { // type would be 'text' in this example } }