@@ -20,15 +20,14 @@ export class KeyUpComponent_v1 {
2020// #enddocregion key-up-component-1-class, key-up-component-1-class-no-type
2121 /*
2222 // #docregion key-up-component-1-class-no-type
23- // without strong typing
24- onKey(event:any) {
23+ onKey(event:any) { // without type info
2524 this.values += event.target.value + ' | ';
2625 }
2726 // #enddocregion key-up-component-1-class-no-type
2827 */
2928 // #docregion key-up-component-1-class
30- // with strong typing
31- onKey ( event : KeyboardEvent ) {
29+
30+ onKey ( event : KeyboardEvent ) { // with type info
3231 this . values += ( < HTMLInputElement > event . target ) . value + ' | ' ;
3332 }
3433// #docregion key-up-component-1-class-no-type
@@ -53,37 +52,37 @@ export class KeyUpComponent_v2 {
5352}
5453// #enddocregion key-up-component-2
5554
56-
5755//////////////////////////////////////////
5856
5957// #docregion key-up-component-3
6058@Component ( {
6159 selector : 'key-up3' ,
6260 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>
6563 `
6664} )
6765export class KeyUpComponent_v3 {
68- values = '' ;
66+ value = '' ;
67+ onEnter ( value : string ) { this . value = value ; }
6968}
7069// #enddocregion key-up-component-3
7170
72-
7371//////////////////////////////////////////
7472
7573// #docregion key-up-component-4
7674@Component ( {
7775 selector : 'key-up4' ,
7876 template : `
7977 <input #box
80- (keyup.enter)="values= box.value"
81- (blur)="values= box.value">
78+ (keyup.enter)="update( box.value) "
79+ (blur)="update( box.value) ">
8280
83- <p>{{values }}</p>
81+ <p>{{value }}</p>
8482 `
8583} )
8684export class KeyUpComponent_v4 {
87- values = '' ;
85+ value = '' ;
86+ update ( value : string ) { this . value = value ; }
8887}
8988// #enddocregion key-up-component-4
0 commit comments