1 import { Component, OnInit } from '@angular/core';
2 import { ActivatedRoute } from '@angular/router';
3 import { Location } from '@angular/common';
5 import { HeroService } from '../hero.service';
6 import { Hero } from '../hero';
9 selector: 'app-hero-detail',
10 templateUrl: './hero-detail.component.html',
11 styleUrls: ['./hero-detail.component.css']
13 export class HeroDetailComponent implements OnInit {
18 private route: ActivatedRoute,
19 private heroService: HeroService,
20 private location: Location
28 this.route.params.subscribe(params => {
29 const id: number = +params.id;
30 this.heroService.getHero(id).subscribe(hero => this.hero = hero);