- 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.
34 lines
721 B
Dart
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
|