javascript / beginner
Snippet
Emitting Events with @Output
Components use @Output properties combined with EventEmitter to send data or notifications back up to their parent component.
snippet.js
1
2
3
4
5
@Output() statusChanged = new EventEmitter<boolean>();updateStatus(val: boolean) {this.statusChanged.emit(val);}
angular
Breakdown
1
@Output()
Marks the property as an event source for the parent.
2
emit(val)
Triggers the event and passes the value 'val' to the listener.