1
- import { Component , Input , WrappedValue , ChangeDetectionStrategy } from '@angular/core' ;
1
+ import { Component , Input , WrappedValue , ChangeDetectionStrategy , AfterViewChecked , DoCheck } from '@angular/core' ;
2
2
import { Label } from 'ui/label' ;
3
3
import { ObservableArray } from 'data/observable-array' ;
4
4
@@ -8,24 +8,34 @@ class DataItem {
8
8
9
9
@Component ( {
10
10
selector : 'item-component' ,
11
- styleUrls : [ 'examples/list/styles.css' ] ,
11
+ styleUrls : [ 'examples/list/styles.css' ] ,
12
+ // changeDetection: ChangeDetectionStrategy.OnPush,
12
13
template : `
13
14
<StackLayout [class.odd]="odd" [class.even]="even">
14
- <Label [text]='"[" + data.id + "]name: " + data.name'></Label>
15
+ <Label [text]='"[" + data.id + "]: " + data.name'></Label>
15
16
</StackLayout>
16
17
`
17
18
} )
18
- export class ItemComponent {
19
+ export class ItemComponent implements AfterViewChecked , DoCheck {
19
20
@Input ( ) data : DataItem ;
20
21
@Input ( ) odd : boolean ;
21
22
@Input ( ) even : boolean ;
22
23
constructor ( ) { }
24
+
25
+ ngDoCheck ( ) {
26
+ // console.log("ItemComponent.ngDoCheck: " + this.data.id);
27
+ }
28
+
29
+ ngAfterViewChecked ( ) {
30
+ // console.log("ItemComponent.ngAfterViewChecked: " + this.data.id);
31
+ }
23
32
}
24
33
25
34
@Component ( {
26
35
selector : 'list-test' ,
27
36
styleUrls : [ 'examples/list/styles.css' ] ,
28
37
directives : [ ItemComponent ] ,
38
+ // changeDetection: ChangeDetectionStrategy.OnPush,
29
39
template : `
30
40
<GridLayout rows="auto * auto" columns="* *">
31
41
<Label text="ListView" class="list-title"></Label>
@@ -36,7 +46,6 @@ export class ItemComponent {
36
46
<item-component [data]="item" [odd]="odd" [even]="even"></item-component>
37
47
</template>
38
48
</ListView>
39
-
40
49
<StackLayout row="1" col="1" margin="10">
41
50
<StackLayout *ngFor="let item of myItems; let odd = odd; let even = even"
42
51
[class.odd]="odd" [class.even]="even" marginBottom="1">
@@ -46,11 +55,10 @@ export class ItemComponent {
46
55
47
56
<StackLayout row="2" colspan="2" orientation="horizontal">
48
57
<Button text="add item" (tap)="addItem()" ></Button>
49
- <Button text="second test " (tap)="onSecondButtonTap($event )" ></Button>
58
+ <Button text="tap " (tap)="justTap( )" ></Button>
50
59
</StackLayout>
51
60
</GridLayout>
52
- ` ,
53
- changeDetection : ChangeDetectionStrategy . OnPush
61
+ `
54
62
// TEMPLATE WITH COMPONENT
55
63
// <template let-item="item" let-i="index" let-odd="odd" let-even="even">
56
64
// <item-component [data]="item" [odd]='odd' [even]='even'></item-component>
@@ -73,7 +81,7 @@ export class ListTest {
73
81
//this.myItems = new ObservableArray<DataItem>();
74
82
this . myItems = [ ] ;
75
83
this . counter = 0 ;
76
- for ( var i = 0 ; i < 10 ; i ++ ) {
84
+ for ( var i = 0 ; i < 2 ; i ++ ) {
77
85
this . myItems . push ( new DataItem ( i , "data item " + i ) ) ;
78
86
this . counter = i ;
79
87
}
@@ -88,9 +96,7 @@ export class ListTest {
88
96
this . myItems . push ( new DataItem ( this . counter , "data item " + this . counter ) ) ;
89
97
}
90
98
91
- onSecondButtonTap ( args ) {
92
- var page = args . object . page ;
93
- var label = < Label > page . getViewById ( "testLabel" ) ;
94
- label . text = "Alabala" ;
99
+ justTap ( ) {
100
+ console . log ( "----------------- TAP -----------------" ) ;
95
101
}
96
102
}
0 commit comments