@@ -20,15 +20,14 @@ export class KeyUpComponent_v1 {
20
20
// #enddocregion key-up-component-1-class, key-up-component-1-class-no-type
21
21
/*
22
22
// #docregion key-up-component-1-class-no-type
23
- // without strong typing
24
- onKey(event:any) {
23
+ onKey(event:any) { // without type info
25
24
this.values += event.target.value + ' | ';
26
25
}
27
26
// #enddocregion key-up-component-1-class-no-type
28
27
*/
29
28
// #docregion key-up-component-1-class
30
- // with strong typing
31
- onKey ( event : KeyboardEvent ) {
29
+
30
+ onKey ( event : KeyboardEvent ) { // with type info
32
31
this . values += ( < HTMLInputElement > event . target ) . value + ' | ' ;
33
32
}
34
33
// #docregion key-up-component-1-class-no-type
@@ -53,37 +52,37 @@ export class KeyUpComponent_v2 {
53
52
}
54
53
// #enddocregion key-up-component-2
55
54
56
-
57
55
//////////////////////////////////////////
58
56
59
57
// #docregion key-up-component-3
60
58
@Component ( {
61
59
selector : 'key-up3' ,
62
60
template : `
63
- <input #box (keyup.enter)="values= box.value">
64
- <p>{{values }}</p>
61
+ <input #box (keyup.enter)="onEnter( box.value) ">
62
+ <p>{{value }}</p>
65
63
`
66
64
} )
67
65
export class KeyUpComponent_v3 {
68
- values = '' ;
66
+ value = '' ;
67
+ onEnter ( value : string ) { this . value = value ; }
69
68
}
70
69
// #enddocregion key-up-component-3
71
70
72
-
73
71
//////////////////////////////////////////
74
72
75
73
// #docregion key-up-component-4
76
74
@Component ( {
77
75
selector : 'key-up4' ,
78
76
template : `
79
77
<input #box
80
- (keyup.enter)="values= box.value"
81
- (blur)="values= box.value">
78
+ (keyup.enter)="update( box.value) "
79
+ (blur)="update( box.value) ">
82
80
83
- <p>{{values }}</p>
81
+ <p>{{value }}</p>
84
82
`
85
83
} )
86
84
export class KeyUpComponent_v4 {
87
- values = '' ;
85
+ value = '' ;
86
+ update ( value : string ) { this . value = value ; }
88
87
}
89
88
// #enddocregion key-up-component-4
0 commit comments