X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fheroes%2Fheroes.component.ts;h=d8ac6427f3a4182b2b48225e65c4a8ab53553f5f;hb=2f6f2d86ff7765914cd9105069181ed1f1792f44;hp=94f426656a78890c89a2966a9d9d7687511858eb;hpb=ef15a90ba71bcff7765f089af11e2ad22752a352;p=examples%2Fangular-tour-of-heroes diff --git a/src/app/heroes/heroes.component.ts b/src/app/heroes/heroes.component.ts index 94f4266..d8ac642 100644 --- a/src/app/heroes/heroes.component.ts +++ b/src/app/heroes/heroes.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Hero } from '../hero'; import { HeroService } from '../hero.service'; +import { MessageService } from '../message.service'; @Component({ selector: 'app-heroes', @@ -15,15 +16,20 @@ export class HeroesComponent implements OnInit { onSelect(hero : Hero): void { this.selectedHero = hero; + this.messageService.add(`HeroService: Selected hero id=${hero.id}`); } - constructor(private heroService : HeroService) { } + constructor( + private heroService : HeroService, + private messageService : MessageService) { } ngOnInit() { this.getHeroes(); } getHeroes() : void { - this.heroes = this.heroService.getHeroes(); + this.heroService + .getHeroes() + .subscribe(heroes => this.heroes = heroes); } }