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;h=4bbfe2ee8c029183eea2fdad97edd6843ee8d459;hp=d4c72891e301a09cc54fd9979ddf5108cd8b0e92;hb=cfdc1d228b90a65ef26d432b62504ee1c0ab0d04;hpb=69d83392a0c41cd9fa012b69efdb5f6f2a046886 diff --git a/src/app/hero-detail/hero-detail.component.ts b/src/app/hero-detail/hero-detail.component.ts index d4c7289..4bbfe2e 100644 --- a/src/app/hero-detail/hero-detail.component.ts +++ b/src/app/hero-detail/hero-detail.component.ts @@ -12,7 +12,7 @@ import { Hero } from '../hero'; }) export class HeroDetailComponent implements OnInit { - hero: Hero; + hero: Hero | undefined; constructor( private route: ActivatedRoute, @@ -27,6 +27,7 @@ export class HeroDetailComponent implements OnInit { getHero(): void { this.route.params.subscribe(params => { const id: number = +params.id; + this.hero = undefined; this.heroService.getHero(id).subscribe(hero => this.hero = hero); }); }