parent
a979c71089
commit
3d868da4b7
|
@ -19,9 +19,8 @@ export class HeroService {
|
||||||
|
|
||||||
//#docregion get-hero
|
//#docregion get-hero
|
||||||
getHero(id: number) {
|
getHero(id: number) {
|
||||||
return Promise.resolve(HEROES).then(
|
return this.getHeroes()
|
||||||
heroes => heroes.filter(hero => hero.id === id)[0]
|
.then(heroes => heroes.filter(hero => hero.id === id)[0]);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
//#enddocregion get-hero
|
//#enddocregion get-hero
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,7 +427,7 @@ code-example(format='').
|
||||||
The problem with this bit of code is that `HeroService` doesn't have a `getHero` method!
|
The problem with this bit of code is that `HeroService` doesn't have a `getHero` method!
|
||||||
We better fix that quickly before someone notices that we broke the app.
|
We better fix that quickly before someone notices that we broke the app.
|
||||||
|
|
||||||
Open `HeroService` and add the `getHero` method. It's trivial given that we're still faking data access:
|
Open `HeroService` and add a `getHero` method that filters the heroes list from `getHeroes` by `id`:
|
||||||
+makeExample('toh-5/ts/app/hero.service.ts', 'get-hero', 'app/hero.service.ts (getHero)')(format=".")
|
+makeExample('toh-5/ts/app/hero.service.ts', 'get-hero', 'app/hero.service.ts (getHero)')(format=".")
|
||||||
:marked
|
:marked
|
||||||
Return to the `HeroDetailComponent` to clean up loose ends.
|
Return to the `HeroDetailComponent` to clean up loose ends.
|
||||||
|
|
Loading…
Reference in New Issue