-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
40 lines (32 loc) · 817 Bytes
/
app.ts
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
/// <reference path="typings/angular2/angular2.d.ts" />
import {Component, View, bootstrap, NgFor, NgIf} from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@View({
template: `
<h1 *ng-if="isSearched">{{ name }}, is a Cheater!!!</h1>
<input #nametext (keyup)="doneTyping($event)">
<button (click)="searchName(nametext.value)">Search Name</button>`,
directives: [NgFor, NgIf]
// template: '<h1>Hello {{ name }}</h1>'
})
class CheaterComponent {
name: string;
isSearched: boolean;
constructor() {
this.name = 'Alice';
this.isSearched = false;
}
searchName(sName: string) {
this.name = sName;
this.isSearched = true;
}
doneTyping($event) {
if($event.which === 13) {
this.searchName($event.target.value);
$event.target.value = null;
}
}
}
bootstrap(CheaterComponent);