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.
38 lines
1003 B
Dart
38 lines
1003 B
Dart
// #docregion
|
|
import 'package:angular2/core.dart';
|
|
import 'package:stream_transformers/stream_transformers.dart';
|
|
|
|
import 'wikipedia_service.dart';
|
|
|
|
@Component(
|
|
selector: 'my-wiki-smart',
|
|
template: '''
|
|
<h1>Smarter Wikipedia Demo</h1>
|
|
<p><i>Fetches when typing stops</i></p>
|
|
|
|
<input #term (keyup)="search(term.value)"/>
|
|
<ul>
|
|
<li *ngFor="let item of items">{{item}}</li>
|
|
</ul>
|
|
''',
|
|
providers: const [WikipediaService])
|
|
class WikiSmartComponent {
|
|
final WikipediaService _wikipediaService;
|
|
List items = [];
|
|
|
|
WikiSmartComponent(this._wikipediaService) {
|
|
_searchTermStream
|
|
.transform(new Debounce(new Duration(milliseconds: 300)))
|
|
.distinct()
|
|
.transform(new FlatMapLatest(
|
|
(term) => _wikipediaService.search(term).asStream()))
|
|
.forEach((data) {
|
|
items = data;
|
|
});
|
|
}
|
|
|
|
final EventEmitter _searchTermStream = new EventEmitter();
|
|
|
|
void search(String term) => _searchTermStream.add(term);
|
|
}
|