1 import { Component, OnInit, Input } 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 const id = +this.route.snapshot.paramMap.get('id');
29 this.heroService.getHero(id).subscribe(hero => this.hero = hero);