Directive class

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) { = '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


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


exportAs → String
A name that can be used in the template to assign this directive to a variable. [...]
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. [...]
selector → String
The CSS selector that triggers the instantiation of the directive. [...]
visibility Visibility
Whether this directive will be provided for injection.
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


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


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