1: The Hero Editor
authorKai Moritz <kai@juplo.de>
Fri, 1 May 2020 17:31:56 +0000 (19:31 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 1 May 2020 17:31:56 +0000 (19:31 +0200)
c) Create a Hero interface + Show the hero object

src/app/hero.ts [new file with mode: 0644]
src/app/heroes/heroes.component.html
src/app/heroes/heroes.component.ts

diff --git a/src/app/hero.ts b/src/app/hero.ts
new file mode 100644 (file)
index 0000000..a61b497
--- /dev/null
@@ -0,0 +1,4 @@
+export interface Hero {
+  id: number;
+  name: string;
+}
index 6fe45e5..c48ee17 100644 (file)
@@ -1 +1,3 @@
-{{hero}}
+<h2>{{hero.name}} Details</h2>
+<div><span>id: </span>{{hero.id}}</div>
+<div><span>name: </span>{{hero.name}}</div>
index b8b6314..dd46908 100644 (file)
@@ -1,4 +1,5 @@
 import { Component, OnInit } from '@angular/core';
+import { Hero } from '../hero';
 
 @Component({
   selector: 'app-heroes',
@@ -7,7 +8,10 @@ import { Component, OnInit } from '@angular/core';
 })
 export class HeroesComponent implements OnInit {
 
-  hero = 'Windstorm';
+  hero: Hero = {
+    id: 1,
+    name: 'Windstorm',
+  };
 
   constructor() { }