Skip to content

Commit

Permalink
feat(params): update extraction of the id param for hero detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismaestro authored and Ismael Ramos committed Apr 18, 2018
1 parent 0b3bd62 commit 0deda48
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/app/heroes/hero-detail/hero-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ export class HeroDetailComponent implements OnInit {
}

ngOnInit() {
this.activatedRoute.params.subscribe((params: any) => {
if (params['id']) {
this.heroService.getHeroById(params['id']).subscribe((hero: Hero) => {
this.hero = hero;
});
}
const heroId = this.activatedRoute.snapshot.paramMap.get('id');
this.heroService.getHeroById(heroId).subscribe((hero: Hero) => {
this.hero = hero;
});
}

Expand Down

0 comments on commit 0deda48

Please sign in to comment.