Mainly copyedits, but also - Dart .jade extends TS .jade file with minor overrides - Significant update of example code (so it matches the ts example in its appearance and behavior). - Tweaks to Dart code. - A few extra/corrected mixin definitions in `_util-fns.jade`.
41 lines
879 B
Dart
41 lines
879 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 [Spy],
|
|
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();
|
|
}
|
|
}
|