This repository was archived by the owner on Feb 17, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-38
lines changed Expand file tree Collapse file tree 3 files changed +16
-38
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ <h1>Hello Angular 2 and Webpack 2</h1>
6
6
< a href ="# " [routerLink] ="[''] "> Home</ a >
7
7
< a href ="# " [routerLink] ="['about'] "> About</ a >
8
8
< a href ="# " [routerLink] ="['yolo'] "> Yolo</ a >
9
- < reactive > </ reactive >
9
+ < reactive-app > </ reactive-app >
10
10
11
11
< div > Your Content Here</ div >
12
12
< router-outlet > </ router-outlet >
Original file line number Diff line number Diff line change 1
1
import { exportNgModules } from '../_helpers/ng-module' ;
2
2
3
- import { Reactive } from './reactive' ;
3
+ import {
4
+ ReactiveApp ,
5
+ Incrementer ,
6
+ AcApp ,
7
+ AngularclassApp ,
8
+ } from './reactive' ;
4
9
5
10
export * from './reactive' ;
6
11
export default exportNgModules ( {
7
- entryComponent : Reactive ,
12
+ entryComponent : ReactiveApp ,
8
13
routes : [ ] ,
9
14
directives : [
10
-
15
+ Incrementer ,
16
+ AngularclassApp ,
17
+ AcApp
11
18
] ,
12
19
providers : [ ] ,
13
20
pipes : [ ]
Original file line number Diff line number Diff line change @@ -6,22 +6,17 @@ import { AppStore } from '../app-store';
6
6
7
7
//normal component with @Output event
8
8
@Component ( {
9
- selector : 'incrementer' ,
10
9
template : `
11
10
<div>
12
11
<button (click)="increments.emit(1)">increment</button>
13
12
</div>`
14
13
} )
15
- class Incrementer {
14
+ export class Incrementer {
16
15
@Output ( ) increments = new EventEmitter ( ) ;
17
16
}
18
17
19
18
20
19
@Component ( {
21
- selector : 'angularclass-app' ,
22
- directives : [
23
- Incrementer
24
- ] ,
25
20
template : `
26
21
<div>
27
22
<h4>Child Total Count: {{ appStore.changes.pluck('counter') | async }}</h4>
@@ -53,10 +48,6 @@ export class AngularclassApp {
53
48
}
54
49
55
50
@Component ( {
56
- selector : 'ac-app' ,
57
- directives : [
58
- AngularclassApp
59
- ] ,
60
51
template : `
61
52
<div>
62
53
<h3>Parent Total Count: {{ counter }}</h3>
@@ -70,48 +61,28 @@ export class AcApp {
70
61
// we can abuse everything to get what we want
71
62
@Output ( ) @ObserveViewChild ( AngularclassApp ) counterChange = new EventEmitter ( ) ;
72
63
73
- ngOnInit ( ) {
74
-
75
- }
76
64
77
65
}
78
66
79
67
@Component ( {
80
- selector : 'app' ,
81
- directives : [ AcApp ] ,
82
68
template : `
83
69
<div>
84
70
<h2>Root Total Count: {{ counter }}</h2>
85
- <ac-app (counterChange)="counter = $event"></ac-app>
71
+ <ac-app (counterChange)="$event"></ac-app>
86
72
</div>
87
73
`
88
74
} )
89
- export class App {
75
+ export class ReactiveApp {
90
76
get counter ( ) {
91
77
return this . appStore . getValue ( 'counter' ) ;
92
78
}
79
+
93
80
@ObserveViewChild ( AcApp ) counterChange = new EventEmitter ( ) ;
81
+
94
82
constructor ( public appStore : AppStore ) {
95
83
96
84
97
85
this . counterChange . subscribe ( data => this . appStore . setValue ( 'counter' , data ) ) ;
98
86
}
99
- ngOnInit ( ) {
100
- }
101
-
102
- }
103
-
104
- @Component ( {
105
- directives : [
106
- App
107
- ] ,
108
- template : `
109
- <div>
110
- Reactive
111
- <app></app>
112
- </div>
113
- `
114
- } )
115
- export class Reactive {
116
87
117
88
}
You can’t perform that action at this time.
0 commit comments