From bc2bcd6cfedf856a198715419ac97eea9c14f3c5 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 2 May 2020 12:38:51 +0200 Subject: [PATCH] 2: Display a List b) Master/Detail --- src/app/heroes/heroes.component.html | 14 ++++++++------ src/app/heroes/heroes.component.ts | 9 +++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/app/heroes/heroes.component.html b/src/app/heroes/heroes.component.html index dd417cf..cd87f96 100644 --- a/src/app/heroes/heroes.component.html +++ b/src/app/heroes/heroes.component.html @@ -1,12 +1,14 @@

My Heroes

-

{{hero.name | uppercase}} Details

-
id: {{hero.id}}
-
- - +
+

{{selectedHero.name | uppercase}} Details

+
id: {{selectedHero.id}}
+
+ + +
diff --git a/src/app/heroes/heroes.component.ts b/src/app/heroes/heroes.component.ts index 2bb7a69..a09ff13 100644 --- a/src/app/heroes/heroes.component.ts +++ b/src/app/heroes/heroes.component.ts @@ -11,10 +11,11 @@ export class HeroesComponent implements OnInit { heroes = HEROES; - hero: Hero = { - id: 1, - name: 'Windstorm', - }; + selectedHero : Hero; + + onSelect(hero : Hero): void { + this.selectedHero = hero; + } constructor() { } -- 2.20.1