Patrice Chalin e5b11d456c docs(guide/attribute-directives): follow-up to #1654 (#1765)
- Updated Dart code to match TS.
- Ran dartfmt.
- Enabled e2e tests; suites passed:
  - public/docs/_examples/attribute-directives/dart
  - public/docs/_examples/attribute-directives/ts
- Prose copyedits.
2016-06-28 13:15:51 -07:00

34 lines
721 B
Dart

// #docregion
import 'package:angular2/core.dart';
@Directive(selector: '[myHighlight]')
class HighlightDirective {
// #docregion ctor
final dynamic _el;
HighlightDirective(ElementRef elRef) : _el = elRef.nativeElement;
// #enddocregion ctor
// #docregion mouse-methods, host
@HostListener('mouseenter')
void onMouseEnter() {
// #enddocregion host
_highlight('yellow');
// #docregion host
}
@HostListener('mouseleave')
void onMouseLeave() {
// #enddocregion host
_highlight();
// #docregion host
}
// #enddocregion host
void _highlight([String color]) {
if (_el != null) _el.style.backgroundColor = color;
}
// #enddocregion mouse-methods
}
// #enddocregion