@@ -32,18 +32,28 @@ import {GreetModel} from '../models/GreetModel';
32
32
} )
33
33
@View ( {
34
34
template : `
35
+ <div>
35
36
counter {{ counter }}
36
- <button (click)="incrementCounter()">Increment Counter from Component</button>
37
+
38
+ <div>
39
+ <button (click)="incrementCounter()">
40
+ Increment Counter from Component
41
+ </button>
42
+ <content></content>
43
+ </div>
44
+
45
+ </div>
37
46
`
38
47
} )
39
48
export class Count {
49
+ counter : number ;
40
50
counterIntent : CounterIntent ;
41
51
constructor ( counterIntent : CounterIntent ) {
42
52
this . counterIntent = counterIntent ;
43
53
}
44
54
45
55
onChange ( value ) {
46
- console . log ( 'CHANGE Count' , value ) ;
56
+ console . log ( 'CHANGE Count\n ' , JSON . stringify ( value , null , 2 ) ) ;
47
57
}
48
58
incrementCounter ( ) {
49
59
this . counterIntent . incrementCounter ( ) ;
@@ -62,21 +72,24 @@ export class Count {
62
72
directives : [ routerDirectives , coreDirectives , Count ] ,
63
73
template : `
64
74
65
- <h1 class="title">{{ state.greeting }} </h1>
75
+ <h1 class="title">Hello Reactive Angular 2 </h1>
66
76
67
77
68
- <count [counter]="state.counter"></count>
69
- <button (click)="handleIncrement()">Increment Counter from App</button>
78
+ <count [counter]="state.counter">
79
+ <button (click)="handleIncrement()">Increment Counter from App</button>
80
+ </count>
70
81
71
82
<h2>Greet {{ state.greeting }}</h2>
72
83
<div>
73
84
<button (^click)="toggleGreet()">Greet {{ state.greeting }} </button>
74
85
</div>
75
- <pre>AppState = {{ state | json }}</pre>
86
+ <pre>state = {{ state | json }}</pre>
87
+ <pre>appState = {{ appState | async | json }}</pre>
76
88
`
77
89
} )
78
90
export class App {
79
91
state : any ;
92
+ appState : any ;
80
93
// public isn't working for me here :/
81
94
counter : CounterModel ; counterIntent : CounterIntent ;
82
95
greet : GreetModel ; greetIntent : GreetIntent ;
@@ -87,13 +100,13 @@ export class App {
87
100
88
101
this . state = { } ;
89
102
90
- var appState = Rx . Observable . merge (
103
+ this . appState = Rx . Observable . merge (
91
104
this . counter . subject . toRx ( ) ,
92
105
this . greet . subject . toRx ( )
93
106
) ;
94
107
95
108
96
- appState . subscribe ( results => {
109
+ this . appState . subscribe ( results => {
97
110
this . state = Object . assign ( { } , this . state , results )
98
111
} ) ;
99
112
@@ -108,7 +121,7 @@ export class App {
108
121
}
109
122
// doesn't work at the moment
110
123
onChange ( value ) {
111
- console . log ( 'CHANGE App' , value ) ;
124
+ console . log ( 'CHANGE App\n ' , JSON . stringify ( value , null , 2 ) ) ;
112
125
}
113
126
}
114
127
0 commit comments