import { Component, OnInit } from '@angular/core';
import { Hero } from '../hero';
import { HeroService } from '../hero.service';
+import { MessageService } from '../message.service';
@Component({
selector: 'app-heroes',
onSelect(hero : Hero): void {
this.selectedHero = hero;
+ this.messageService.add(`HeroService: Selected hero id=${hero.id}`);
}
- constructor(private heroService : HeroService) { }
+ constructor(
+ private heroService : HeroService,
+ private messageService : MessageService) { }
ngOnInit() {
this.getHeroes();