HostBinding class

Declares a host property on the host component or element.

This annotation is valid on:

  • Public class members
  • The class members may either be fields or getters
  • The class members may either be static or instance

This annotation is inherited if declared on an instance member.

If hostPropertyName is not specified, it defaults to the property or getter name. For example in the following, 'title' is implicitly used:

@Directive(...)
class ImplicitName {
  // Same as @HostBinding('title')
  @HostBinding()
  final title = 'Hello World';
}

These bindings are nearly identical to using the template syntax to set properties or attributes, and are automatically updated if the referenced class member, instance or static, changes:

@Directive(...)
class HostBindingExample {
  // Similar to <example [value]="hostValue"> in a template.
  @HostBinding('value')
  String hostValue;

  // Similar to <example [attr.debug-id]="debugId"> in a template.
  @HostBinding('attr.debug-id')
  String debugId;
}

Constructors

HostBinding([String hostPropertyName ])
const

Properties

hostPropertyName → String
final
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited