angular-docs-cn/public/docs/_examples/user-input/dart/lib/little_tour_component.dart
Patrice Chalin ff20b55975 chore(dart & ts): update to beta.17
Change `ngFor=“#…”` to `ngFor=“let…` in code. All are .dart files
except for `app_component.html` which also has changes for:
- `<inpuf var-foo…`> to `<input ref-foo…>`
- `#docregion` tag name updates from var-foo to ref-foo.
- Other misc updates to minimize diffs with TS version of file,
whitespace differences were ignored.

+ Minor update to sync up Dart prose with TS prose.

+ Used
https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer#resol
ved_identifiers to solve
https://github.com/angular/angular.io/issues/1033

Guide/pipes not updated as it will be rolled back to
beta.15 in PR #1220.
2016-04-30 15:01:16 +01:00

26 lines
630 B
Dart

// #docregion
import 'package:angular2/core.dart';
// #docregion little-tour
@Component(
selector: 'little-tour',
template: '''
<input #newHero
(keyup.enter)="addHero(newHero.value)"
(blur)="addHero(newHero.value); newHero.value='' ">
<button (click)=addHero(newHero.value)>Add</button>
<ul><li *ngFor="let hero of heroes">{{hero}}</li></ul>
''')
class LittleTourComponent {
List<String> heroes = ['Windstorm', 'Bombasto', 'Magneta', 'Tornado'];
void addHero(String newHero) {
if (newHero?.length > 0) {
heroes.add(newHero);
}
}
}
// #enddocregion little-tour