Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 5103d15

Browse files
committed
chore: use fake ngModule
1 parent 20a8da4 commit 5103d15

File tree

3 files changed

+16
-38
lines changed

3 files changed

+16
-38
lines changed

src/app/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1>Hello Angular 2 and Webpack 2</h1>
66
<a href="#" [routerLink]="['']">Home</a>
77
<a href="#" [routerLink]="['about']">About</a>
88
<a href="#" [routerLink]="['yolo']">Yolo</a>
9-
<reactive></reactive>
9+
<reactive-app></reactive-app>
1010

1111
<div>Your Content Here</div>
1212
<router-outlet></router-outlet>

src/app/reactive/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import {exportNgModules} from '../_helpers/ng-module';
22

3-
import {Reactive} from './reactive';
3+
import {
4+
ReactiveApp,
5+
Incrementer,
6+
AcApp,
7+
AngularclassApp,
8+
} from './reactive';
49

510
export * from './reactive';
611
export default exportNgModules({
7-
entryComponent: Reactive,
12+
entryComponent: ReactiveApp,
813
routes: [],
914
directives: [
10-
15+
Incrementer,
16+
AngularclassApp,
17+
AcApp
1118
],
1219
providers: [],
1320
pipes: []

src/app/reactive/reactive.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,17 @@ import { AppStore } from '../app-store';
66

77
//normal component with @Output event
88
@Component({
9-
selector: 'incrementer',
109
template: `
1110
<div>
1211
<button (click)="increments.emit(1)">increment</button>
1312
</div>`
1413
})
15-
class Incrementer {
14+
export class Incrementer {
1615
@Output() increments = new EventEmitter();
1716
}
1817

1918

2019
@Component({
21-
selector: 'angularclass-app',
22-
directives: [
23-
Incrementer
24-
],
2520
template: `
2621
<div>
2722
<h4>Child Total Count: {{ appStore.changes.pluck('counter') | async }}</h4>
@@ -53,10 +48,6 @@ export class AngularclassApp {
5348
}
5449

5550
@Component({
56-
selector: 'ac-app',
57-
directives: [
58-
AngularclassApp
59-
],
6051
template: `
6152
<div>
6253
<h3>Parent Total Count: {{ counter }}</h3>
@@ -70,48 +61,28 @@ export class AcApp {
7061
// we can abuse everything to get what we want
7162
@Output() @ObserveViewChild(AngularclassApp) counterChange = new EventEmitter();
7263

73-
ngOnInit() {
74-
75-
}
7664

7765
}
7866

7967
@Component({
80-
selector: 'app',
81-
directives: [AcApp],
8268
template: `
8369
<div>
8470
<h2>Root Total Count: {{ counter }}</h2>
85-
<ac-app (counterChange)="counter = $event"></ac-app>
71+
<ac-app (counterChange)="$event"></ac-app>
8672
</div>
8773
`
8874
})
89-
export class App {
75+
export class ReactiveApp {
9076
get counter() {
9177
return this.appStore.getValue('counter');
9278
}
79+
9380
@ObserveViewChild(AcApp) counterChange = new EventEmitter();
81+
9482
constructor(public appStore: AppStore) {
9583

9684

9785
this.counterChange.subscribe(data => this.appStore.setValue('counter', data));
9886
}
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 {
11687

11788
}

0 commit comments

Comments
 (0)