Angular 8: Component Interaction using Service

Angular 8

In Angular 8, components communicate with each other to share data such as object, string, etc..

Components are made of typescript class and html template. We often required to update data of component based on the changes of the other component. In previous articles Calling Child Method from Parent Component using Temp Ref Variable and Angular5+ Communicating from child component to parent component we understand communication from child to parent and visa versa. Continue reading

Angular5+ Communicating from child component to parent component

Communicating from child to parent always a trouble for the developer. There are many situations where we dev want to update parent component based on some result of child component.

Here is solution that will guide you how child can send output(Events) to the parent.

In Angular, a component can emit an event using @Output and EventEmitter. Both are parts of the @angular/core.

Now on parent component where we using this child component.

Here anyParentMehtod is method name of parent component. $event will be result wht you have sent from the child component.

Hope you understood basics concept. Feel free to comment.