X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fhero-detail%2Fhero-detail.component.ts;h=4bbfe2ee8c029183eea2fdad97edd6843ee8d459;hb=cfdc1d228b90a65ef26d432b62504ee1c0ab0d04;hp=aef0da51f688957494410246dd1a1e77bd56e3a8;hpb=f6721b579dc10a1412804c1ab78c7865d6d91dd0;p=examples%2Fangular-tour-of-heroes diff --git a/src/app/hero-detail/hero-detail.component.ts b/src/app/hero-detail/hero-detail.component.ts index aef0da5..4bbfe2e 100644 --- a/src/app/hero-detail/hero-detail.component.ts +++ b/src/app/hero-detail/hero-detail.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; @@ -12,7 +12,7 @@ import { Hero } from '../hero'; }) export class HeroDetailComponent implements OnInit { - @Input() 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); }); }