Patrice Chalin eda47f64e8 docs(guide/lifecycle-hooks): follow-up to #1654 (#1768)
Mainly Dart-side review, following #1654:
- Updates to follow style guide
- Enabled e2e tests
- Fixes to ensure tests pass: in after_view_component.dart and
after_content_component.dart
  - Changed test over comment field in template to be:
*ngIf="comment.isNotEmpty"
- Suites passed:
  public/docs/_examples/lifecycle-hooks/dart
  public/docs/_examples/lifecycle-hooks/ts
2016-06-28 13:13:58 -07:00

24 lines
523 B
Dart

// #docregion
import 'package:angular2/core.dart';
import 'logger_service.dart';
int _nextId = 1;
// #docregion spy-directive
// Spy on any element to which it is applied.
// Usage: <div mySpy>...</div>
@Directive(selector: '[mySpy]')
class SpyDirective implements OnInit, OnDestroy {
final LoggerService _logger;
SpyDirective(this._logger);
ngOnInit() => _logIt('onInit');
ngOnDestroy() => _logIt('onDestroy');
_logIt(String msg) => _logger.log('Spy #${_nextId++} $msg');
}
// #enddocregion spy-directive