parent
fdbb7b5184
commit
dba3a8f9c9
|
@ -13,7 +13,7 @@ export class HeroService {
|
|||
];
|
||||
|
||||
getHeroById(id: number): Hero {
|
||||
return this.heroes.filter(hero => hero.id === id)[0];
|
||||
return this.heroes.find(hero => hero.id === id);
|
||||
}
|
||||
|
||||
getAllHeroes(): Array<Hero> {
|
||||
|
|
|
@ -21,7 +21,7 @@ export class CrisisService {
|
|||
|
||||
getCrisis(id: number | string) {
|
||||
return crisesPromise
|
||||
.then(crises => crises.filter(c => c.id === +id)[0]);
|
||||
.then(crises => crises.find(c => c.id === +id));
|
||||
}
|
||||
|
||||
// #enddocregion
|
||||
|
|
|
@ -22,6 +22,6 @@ export class HeroService {
|
|||
|
||||
getHero(id: number | string) {
|
||||
return heroesPromise
|
||||
.then(heroes => heroes.filter(h => h.id === +id)[0]);
|
||||
.then(heroes => heroes.find(h => h.id === +id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export class CrisisService {
|
|||
|
||||
getCrisis(id: number | string) {
|
||||
return crisesPromise
|
||||
.then(crises => crises.filter(c => c.id === +id)[0]);
|
||||
.then(crises => crises.find(crisis => crisis.id === +id));
|
||||
}
|
||||
|
||||
// #enddocregion
|
||||
|
|
|
@ -22,6 +22,6 @@ export class HeroService {
|
|||
|
||||
getHero(id: number | string) {
|
||||
return heroesPromise
|
||||
.then(heroes => heroes.filter(h => h.id === +id)[0]);
|
||||
.then(heroes => heroes.find(hero => hero.id === +id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ export class HeroService {
|
|||
// #docregion get-hero
|
||||
getHero(id: number) {
|
||||
return Promise.resolve(HEROES).then(
|
||||
heroes => heroes.filter(hero => hero.id === id)[0]
|
||||
heroes => heroes.find(hero => hero.id === id)
|
||||
);
|
||||
}
|
||||
// #enddocregion get-hero
|
||||
|
|
|
@ -20,7 +20,7 @@ export class HeroService {
|
|||
// #docregion get-hero
|
||||
getHero(id: number) {
|
||||
return this.getHeroes()
|
||||
.then(heroes => heroes.filter(hero => hero.id === id)[0]);
|
||||
.then(heroes => heroes.find(hero => hero.id === id));
|
||||
}
|
||||
// #enddocregion get-hero
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ export class HeroService {
|
|||
|
||||
getHero(id: number) {
|
||||
return this.getHeroes()
|
||||
.then(heroes => heroes.filter(hero => hero.id === id)[0]);
|
||||
.then(heroes => heroes.find(hero => hero.id === id));
|
||||
}
|
||||
|
||||
// #docregion save
|
||||
|
|
Loading…
Reference in New Issue