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

41 lines
886 B
Dart

// #docregion
import 'package:angular2/core.dart';
import 'logger_service.dart';
import 'spy_directive.dart';
@Component(
selector: 'spy-parent',
templateUrl: 'spy_component.html',
styles: const [
'.parent {background: khaki}',
'.heroes {background: LightYellow; padding: 0 8px}'
],
directives: const [SpyDirective],
providers: const [LoggerService])
class SpyParentComponent {
final LoggerService _logger;
String newName = 'Herbie';
List<String> heroes = ['Windstorm', 'Magneta'];
SpyParentComponent(this._logger);
List<String> get logs => _logger.logs;
addHero() {
if (newName.trim().isNotEmpty) {
heroes.add(newName.trim());
newName = '';
_logger.tick();
}
}
// removeHero(String hero) { } is not used.
void reset() {
_logger.log('-- reset --');
heroes.clear();
_logger.tick();
}
}