16 lines
317 B
TypeScript
16 lines
317 B
TypeScript
import {Injectable} from '@angular/core';
|
|
import {HEROES} from './mock-heroes';
|
|
|
|
@Injectable()
|
|
export class HeroService {
|
|
getHeroes() {
|
|
return Promise.resolve(HEROES);
|
|
}
|
|
|
|
getHero(id: number) {
|
|
return Promise.resolve(HEROES).then(
|
|
heroes => heroes.filter(hero => hero.id === id)[0]
|
|
);
|
|
}
|
|
}
|