add The searchTerms RxJS subject
This commit is contained in:
parent
ef2309f0f1
commit
f6d361eb84
|
@ -1,7 +1,7 @@
|
|||
<div id="search-component">
|
||||
<label for="search-box">Hero Search</label>
|
||||
<input #searchBox id="search-box" (input)="search(searchBox.value)" />
|
||||
|
||||
|
||||
<ul class="search-result">
|
||||
<li *ngFor="let hero of heroes$ | async" >
|
||||
<a routerLink="/detail/{{hero.id}}">
|
||||
|
@ -9,4 +9,4 @@
|
|||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -37,4 +37,12 @@ export class HeroSearchComponent implements OnInit {
|
|||
switchMap((term: string) => this.heroService.searchHeroes(term)),
|
||||
);
|
||||
}
|
||||
|
||||
private searchTerms = new Subject<string>();
|
||||
|
||||
// Push a search term into the observable stream.
|
||||
search(term: string): void {
|
||||
this.searchTerms.next(term);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue