taking out subscribe. setting results to the observable and using async pipe for *ngFor

master
Matt Huntington 9 years ago
parent a1abfab13a
commit 258ec05097

@ -5,7 +5,7 @@
<section *ngIf="results"> <section *ngIf="results">
<h2>Search Results</h2> <h2>Search Results</h2>
<ul> <ul>
<li *ngFor="let character of results"> <li *ngFor="let character of results | async">
<h3>{{character.name}}</h3> <h3>{{character.name}}</h3>
<dl> <dl>
<dt>Birth Year</dt> <dt>Birth Year</dt>

@ -34,11 +34,10 @@ export class SearchComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.searchTerms this.results = this.searchTerms
.debounceTime(300) .debounceTime(300)
.distinctUntilChanged() .distinctUntilChanged()
.switchMap(name => this.createAPIObservable(name)) .switchMap(name => this.createAPIObservable(name));
.subscribe(results=> this.results = results );
} }
} }

Loading…
Cancel
Save