22 lines
456 B
Dart
22 lines
456 B
Dart
|
// #docregion
|
||
|
import 'package:angular2/angular2.dart';
|
||
|
import 'logger_service.dart';
|
||
|
|
||
|
int nextId = 1;
|
||
|
|
||
|
// Spy on any element to which it is applied.
|
||
|
// Usage: <div mySpy>...</div>
|
||
|
@Directive(selector: '[mySpy]')
|
||
|
class Spy implements OnInit, OnDestroy {
|
||
|
int _id = nextId++;
|
||
|
LoggerService _logger;
|
||
|
|
||
|
Spy(this._logger);
|
||
|
|
||
|
ngOnInit() => _logIt('onInit');
|
||
|
|
||
|
ngOnDestroy() => _logIt('onDestroy');
|
||
|
|
||
|
_logIt(String msg) => _logger.log('Spy #$_id $msg');
|
||
|
}
|