})
export class HeroDetailComponent implements OnInit {
- hero: Hero;
+ hero: Hero | undefined;
constructor(
private route: ActivatedRoute,
getHero(): void {
this.route.params.subscribe(params => {
const id: number = +params.id;
+ this.hero = undefined;
this.heroService.getHero(id).subscribe(hero => this.hero = hero);
});
}