This repository was archived by the owner on Dec 4, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,8 @@ export class HeroService {
19
19
20
20
//#docregion get-hero
21
21
getHero ( id : number ) {
22
- return Promise . resolve ( HEROES ) . then (
23
- heroes => heroes . filter ( hero => hero . id === id ) [ 0 ]
24
- ) ;
22
+ return this . getHeroes ( )
23
+ . then ( heroes => heroes . filter ( hero => hero . id === id ) [ 0 ] ) ;
25
24
}
26
25
//#enddocregion get-hero
27
26
}
Original file line number Diff line number Diff line change @@ -427,7 +427,7 @@ code-example(format='').
427
427
The problem with this bit of code is that `HeroService` doesn't have a `getHero` method!
428
428
We better fix that quickly before someone notices that we broke the app.
429
429
430
- Open `HeroService` and add the `getHero` method. It's trivial given that we're still faking data access :
430
+ Open `HeroService` and add a `getHero` method that filters the heroes list from `getHeroes` by `id` :
431
431
+ makeExample('toh-5/ts/app/hero.service.ts' , 'get-hero' , 'app/hero.service.ts (getHero)' )( format ="." )
432
432
:marked
433
433
Return to the `HeroDetailComponent` to clean up loose ends.
You can’t perform that action at this time.
0 commit comments