X-Git-Url: https://juplo.de/gitweb/?p=examples%2Fangular-tour-of-heroes;a=blobdiff_plain;f=src%2Fapp%2Fhero-detail%2Fhero-detail.component.ts;fp=src%2Fapp%2Fhero-detail%2Fhero-detail.component.ts;h=76e7912fc40ec748fc5aa29a3a36701166d288a5;hp=4bbfe2ee8c029183eea2fdad97edd6843ee8d459;hb=fd92a662c471619278e561f25a4beb7ef78d0690;hpb=cfdc1d228b90a65ef26d432b62504ee1c0ab0d04 diff --git a/src/app/hero-detail/hero-detail.component.ts b/src/app/hero-detail/hero-detail.component.ts index 4bbfe2e..76e7912 100644 --- a/src/app/hero-detail/hero-detail.component.ts +++ b/src/app/hero-detail/hero-detail.component.ts @@ -4,6 +4,7 @@ import { Location } from '@angular/common'; import { HeroService } from '../hero.service'; import { Hero } from '../hero'; +import { MessageService } from '../message.service'; @Component({ selector: 'app-hero-detail', @@ -17,6 +18,7 @@ export class HeroDetailComponent implements OnInit { constructor( private route: ActivatedRoute, private heroService: HeroService, + private messageService: MessageService, private location: Location ) { } @@ -28,7 +30,10 @@ export class HeroDetailComponent implements OnInit { this.route.params.subscribe(params => { const id: number = +params.id; this.hero = undefined; - this.heroService.getHero(id).subscribe(hero => this.hero = hero); + this.heroService.getHero(id).subscribe(hero => { + this.messageService.add('HeroDetailComponent: retrived hero ' + JSON.stringify(hero)); + this.hero = hero; + }); }); }