diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html
index 9223622..22956c9 100644
--- a/src/app/dashboard/dashboard.component.html
+++ b/src/app/dashboard/dashboard.component.html
@@ -5,3 +5,5 @@
{{hero.name}}
+
+
\ No newline at end of file
diff --git a/src/app/hero.service.ts b/src/app/hero.service.ts
index d9316b3..ff3f1f7 100644
--- a/src/app/hero.service.ts
+++ b/src/app/hero.service.ts
@@ -65,6 +65,21 @@ export class HeroService {
catchError(this.handleError('deleteHero'))
);
}
+
+ /* GET heroes whose name contains search term */
+ searchHeroes(term: string): Observable {
+ if (!term.trim()) {
+ // if not search term, return empty hero array.
+ return of([]);
+ }
+ return this.http.get(`${this.heroesUrl}/?name=${term}`)
+ .pipe(
+ tap(x => x.length ?
+ this.log(`found heroes matching "${term}"`) :
+ this.log(`no heroes matching "${term}"`)),
+ catchError(this.handleError('searchHeroes', []))
+ );
+ }
/**
* Handle Http operation that failed.