Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit eb5da41

Browse files
Rafael SotomayorRafael Sotomayor
authored andcommitted
Part2:Hero List
1 parent 3d071e8 commit eb5da41

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

app/app.component.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,51 @@ import { Component } from '@angular/core';
22

33
export class Hero {
44
id: number;
5-
name: string;
5+
name: string;
66
}
77

8+
const HEROES: Hero[] = [
9+
{ id: 11, name: 'Mr. Nice' },
10+
{ id: 12, name: 'Narco' },
11+
{ id: 13, name: 'Bombasto' },
12+
{ id: 14, name: 'Celeritas' },
13+
{ id: 15, name: 'Magneta' },
14+
{ id: 16, name: 'RubberMan' },
15+
{ id: 17, name: 'Dynama' },
16+
{ id: 18, name: 'Dr IQ' },
17+
{ id: 19, name: 'Magma' },
18+
{ id: 20, name: 'Tornado' }
19+
];
20+
821

922
@Component({
1023
selector: 'my-app',
11-
template:`
24+
template: `
1225
<h1>{{title}}</h1>
26+
<h2>My Heroes</h2>
27+
<ul class="heroes" >
28+
<li *ngFor="let hero of heroes">
29+
<!--each hero goes here -- >
30+
<span class="badge">{{hero.id}}</span> {{hero.name}}
31+
</li>
32+
</ul>
33+
1334
<h2>{{hero.name}} details!</h2>
1435
<div><label>id: </label>{{hero.id}}</div>
1536
<div>
1637
<label>name: </label>
1738
<input [(ngModel)]="hero.name" placeholder="name">
18-
</div>
39+
</div>
1940
`
2041

21-
2242
})
2343

24-
export class AppComponent {
25-
title = 'Tour of Heroes';
26-
hero: Hero = {
27-
id: 1,
28-
name: 'Windstorm',
44+
export class AppComponent {
45+
title = 'Tour of Heroes';
46+
hero: Hero = {
47+
id: 1,
48+
name: 'Windstorm',
2949
};
50+
heroes = HEROES;
51+
3052
}

0 commit comments

Comments
 (0)