From 46d25b17344cac082d375ca4626899e117efc4b4 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 2 May 2020 21:52:26 +0200 Subject: [PATCH] 4: Add Services h) Show messages - Add additional messages to hero service --- src/app/heroes/heroes.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/heroes/heroes.component.ts b/src/app/heroes/heroes.component.ts index 1e29d4e..d8ac642 100644 --- a/src/app/heroes/heroes.component.ts +++ b/src/app/heroes/heroes.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Hero } from '../hero'; import { HeroService } from '../hero.service'; +import { MessageService } from '../message.service'; @Component({ selector: 'app-heroes', @@ -15,9 +16,12 @@ export class HeroesComponent implements OnInit { 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(); -- 2.20.1