An annotation that marks a class as an Angular directive, allowing you to attach behavior to elements in the DOM.

import 'package:angular/angular.dart';

@Directive(selector: '[myHighlight]')
class HighlightDirective {
  HighlightDirective(ElementRef el) {
    el.nativeElement.style.backgroundColor = 'yellow';
  }
}

Use @Directive to mark a class as an Angular directive and provide additional metadata that determines how the directive should be processed, instantiated, and used at runtime.

In addition to the metadata configuration specified via the Directive decorator, directives can control their runtime behavior by implementing various lifecycle hooks.

See also:

Implemented by

Constructors

Directive({@required String selector, List<String> inputs, Map<String, String> host, List<Object> providers, String exportAs, Visibility visibility })
const

Properties

exportAs → String
A name that can be used in the template to assign this directive to a variable. [...]
final
host → Map<String, String>
Events, actions, properties, and attributes related to the host element. [...]
@Deprecated('Use @HostBinding() on a getter or @HostListener on a method'), final
inputs → List<String>
The directive's data-bound input properties. [...]
@Deprecated('Use @Input() on a setter or field instead'), final
providers → List<Object>
The set of injectable objects that are visible to the directive and its light DOM children. [...]
final
selector → String
The CSS selector that triggers the instantiation of the directive. [...]
final
visibility Visibility
Whether this directive will be provided for injection.
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 ==(other) → bool
The equality operator. [...]
inherited