What kind of change event, under what conditions does it arise and how can it be used?
That is, what did I subscribe to in the following example via (change)="update()" ?

http://plnkr.co/edit/mfoToOSLU6IU2zr0A8OB?p=preview

 import {Component, View, Input, Output, EventEmitter, OnChanges} from '@angular/core' @Component({ selector: 'inner-component', template: ` <label><input type="checkbox" [(ngModel)]="data.isSelected"> Selected</label> ` }) export class InnerComponent { data = { isSelected: false }; } @Component({ selector: 'my-app', template: ` <p><inner-component (change)="update()"></inner-component></p> <p>The component was updated {{count}} times</p> `, directives: [InnerComponent] }) export class AppComponent { count = 0; update() { ++this.count; } } 

PS: This question is in English.

1 answer 1

This ascent of: change occurs on the input, but floats to the top, where the external component handles it. This can be checked by displaying the event:

http://plnkr.co/edit/J8pRg3ow41PAqdMteKwg?p=preview

 @Component({ selector: 'my-app', template: ` <p><inner-component (change)="update($event)"></inner-component></p> <p>The component was updated {{count}} times</p> `, directives: [InnerComponent] }) export class AppComponent { count = 0; update($event) { console.log($event, $event.target, $event.currentTarget); ++this.count; } }