forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hero.service.ts
34 lines (29 loc) · 953 Bytes
/
hero.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// #docplaster
// #docregion
import { Injectable } from '@angular/core';
// #docregion import-observable
import { Observable, of } from 'rxjs';
// #enddocregion import-observable
// #docregion import-heroes
import { Hero } from './hero';
import { HEROES } from './mock-heroes';
// #enddocregion import-heroes
// #docregion import-message-service
import { MessageService } from './message.service';
// #enddocregion import-message-service
@Injectable({ providedIn: 'root' })
export class HeroService {
// #docregion ctor
constructor(private messageService: MessageService) { }
// #enddocregion ctor
// #docregion getHeroes, getHeroes-1
getHeroes(): Observable<Hero[]> {
// #enddocregion getHeroes-1
// Todo: send the message _after_ fetching the heroes
this.messageService.add('HeroService: fetched heroes');
// #docregion getHeroes-1
return of(HEROES);
}
// #enddocregion getHeroes, getHeroes-1
}
// #enddocregion