Skip to content

Commit 0deda48

Browse files
IsmaestroIsmael Ramos
authored andcommitted
feat(params): update extraction of the id param for hero detail
1 parent 0b3bd62 commit 0deda48

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/app/heroes/hero-detail/hero-detail.component.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ export class HeroDetailComponent implements OnInit {
1919
}
2020

2121
ngOnInit() {
22-
this.activatedRoute.params.subscribe((params: any) => {
23-
if (params['id']) {
24-
this.heroService.getHeroById(params['id']).subscribe((hero: Hero) => {
25-
this.hero = hero;
26-
});
27-
}
22+
const heroId = this.activatedRoute.snapshot.paramMap.get('id');
23+
this.heroService.getHeroById(heroId).subscribe((hero: Hero) => {
24+
this.hero = hero;
2825
});
2926
}
3027

0 commit comments

Comments
 (0)