2016-01-20 16:14:46 -05:00
|
|
|
// #docregion
|
2016-03-25 19:03:53 -04:00
|
|
|
import 'package:angular2/core.dart';
|
2016-01-27 18:51:50 -05:00
|
|
|
|
2016-01-20 16:14:46 -05:00
|
|
|
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');
|
|
|
|
}
|