// #docplaster // #docregion import { Hero } from './hero'; import { HEROES } from './mock-heroes'; import { Injectable } from '@angular/core'; @Injectable() export class HeroService { getHeroes(): Promise { return Promise.resolve(HEROES); } getHeroesSlowly(): Promise { return new Promise(resolve => setTimeout(resolve, 2000)) // delay 2 seconds .then(() => this.getHeroes()); } // #docregion getHero getHero(id: number): Promise { return this.getHeroes() .then(heroes => heroes.find(hero => hero.id === id)); } // #enddocregion getHero }