app.component.html
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<h1>{{title}}</h1>
<div><label>Id: </label>{{hero.id}}</div>
<div><label>Name: </label>{{hero.name}}</div>
<!--One-way binding-->
<h1>One-way binding</h1>
<div>
<input [value]="hero.name">
</div>
<!--Two-way binding-->
<h1>Two-way binding</h1>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
<!--ngFor Example-->
<!--<h1>ngFor</h1>
<h2>My Heroes</h2>
<ul class="heroes">
<li *ngFor="let hero of heroes">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</li>
</ul>-->
<!--Handling Events-->
<h1>ngFor with Event handling</h1>
<h2>My Heroes</h2>
<ul class="heroes">
<li *ngFor="let hero of heroes" (click)="onSelect(hero)">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</li>
</ul>
<!--ngIf-->
<!--<div *ngIf="selectedHero">
<label>name: </label>
<input [(ngModel)]="selectedHero.name" placeholder="name">
</div>-->
<!--Multiple Components-->
<!--<hero-detail [hero]="selectedHero"></hero-detail>-->
<router-outlet></router-outlet>
<!--Routed view go here-->