-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.component.ts
More file actions
36 lines (31 loc) · 1004 Bytes
/
app.component.ts
File metadata and controls
36 lines (31 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Component, Input } from '@angular/core';
import { EventListenerKeys } from './header/Header';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'angular-web-component';
@Input() counter: number = 0;
@Input() reactValue = '';
inputValue = '';
textToReact = '';
increment() {
this.counter++;
}
appNotificationCounter = 0;
notification(event: any) {
// I'm using Angular binding with that @Input
this.appNotificationCounter++;
}
textToReactKeyUp(event: Event) {
// in https://github.com/MachineLlama/multi-app
// the dispatchEvent is used to send data to React
// look for the corresponding document.addEventListener('send-data-to-react', (e) => {
this.textToReact = (event.target as HTMLInputElement).value;
document.dispatchEvent(
new CustomEvent(EventListenerKeys.sendDataToReact, { detail: this.textToReact })
);
}
}