Attribute class

An annotation specifying that a constant attribute value should be injected.

The directive will inject a compile-time constant string literal of the host element's matching attribute.

NOTE: @Attribute is not affected by any updates to attributes to the host element (including the [attr.*] template syntax, or imperative updates to the DOM using dart:html).

Example

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

<input type="text">

A Directive could read the string literal 'text' like so:

@Directive(selector: 'input')
class InputAttrDirective {
  InputAttrDirective(@Attribute('type') String type) {
    print(type); // 'text'
  }
}
Annotations
  • @Target({TargetKind.parameter})

Constructors

Attribute(String attributeName)
const

Properties

attributeName String
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited