c) Create a Hero interface + Show the hero object
--- /dev/null
+export interface Hero {
+ id: number;
+ name: string;
+}
-{{hero}}
+<h2>{{hero.name}} Details</h2>
+<div><span>id: </span>{{hero.id}}</div>
+<div><span>name: </span>{{hero.name}}</div>
import { Component, OnInit } from '@angular/core';
+import { Hero } from '../hero';
@Component({
selector: 'app-heroes',
})
export class HeroesComponent implements OnInit {
- hero = 'Windstorm';
+ hero: Hero = {
+ id: 1,
+ name: 'Windstorm',
+ };
constructor() { }