Angular: Component Communications (Child to Parent)
March 31, 2020
In Angular, the child component has no way of knowing whose its parent is. Thus, in order for data to be sent to a parent component, the parent component must bind to an EventEmitter
object in the Child component to receive the data via the @Output()
directive. The process is similar to how events occur on the browser, such as when a click event or keyup event is triggered on an input or button element. The EventEmitter
is used to emit events from the Child component to the Parent component, and thus data (the payload) can be retrieved for its use.
Note: In Angular, the Child component has no way of knowing its parent component.