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=aef0da51f688957494410246dd1a1e77bd56e3a8;hp=c252bcffe4905eb339cd4ecbd01d71c7690a29f6;hb=f6721b579dc10a1412804c1ab78c7865d6d91dd0;hpb=ee578cce6211199049a491e3119deba48a484478 diff --git a/src/app/hero-detail/hero-detail.component.ts b/src/app/hero-detail/hero-detail.component.ts index c252bcf..aef0da5 100644 --- a/src/app/hero-detail/hero-detail.component.ts +++ b/src/app/hero-detail/hero-detail.component.ts @@ -25,8 +25,10 @@ export class HeroDetailComponent implements OnInit { } getHero(): void { - const id = +this.route.snapshot.paramMap.get('id'); - this.heroService.getHero(id).subscribe(hero => this.hero = hero); + this.route.params.subscribe(params => { + const id: number = +params.id; + this.heroService.getHero(id).subscribe(hero => this.hero = hero); + }); } goBack(): void {