The change event notifies you of a change in the input field. Since your internal component is not a native Angular component, you must specify the event emitter yourself:
@Component({ selector: 'inner-component', template: ` <label><input type="checkbox" (change)="inputChange.emit($event)" [(ngModel)]="data.isSelected"> Selected</label> ` }) export class InnerComponent { @Output('change') inputChange = new EventEmitter(); data = { isSelected: false }; }
And in your AppComponent you now get events:
@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: any) { ++this.count; console.log(event); } }
source share