1 import { Component, OnInit } from '@angular/core';
2 import { Hero } from '../hero';
3 import { HeroService } from '../hero.service';
4 import { MessageService } from '../message.service';
7 selector: 'app-heroes',
8 templateUrl: './heroes.component.html',
9 styleUrls: ['./heroes.component.css']
11 export class HeroesComponent implements OnInit {
17 onSelect(hero : Hero): void {
18 this.selectedHero = hero;
19 this.messageService.add(`HeroService: Selected hero id=${hero.id}`);
23 private heroService : HeroService,
24 private messageService : MessageService) { }
33 .subscribe(heroes => this.heroes = heroes);