1 @Output() open: EventEmitter<any> = new EventEmitter();
2
3
4 toggel() {
5 this.open.emit(null);
6 }
1@Component({
2 selector : 'child',
3 template : `
4 <button (click)="sendNotification()">Notify my parent!</button>
5 `
6})
7class Child {
8 @Output() notifyParent: EventEmitter<any> = new EventEmitter();
9 sendNotification() {
10 this.notifyParent.emit('Some value to send to the parent');
11 }
12}
13
14@Component({
15 selector : 'parent',
16 template : `
17 <child (notifyParent)="getNotification($event)"></child>
18 `
19})
20class Parent {
21 getNotification(evt) {
22 // Do something with the notification (evt) sent by the child!
23 }
24}
1Data flows into your component via property bindings and flows out of your component through event bindings. If you want your component to notify his parent about something you can use the Output decorator with EventEmitter to create a custom event.