Skip to content
Advertisement

How to Pass data from child to parent component Angular

I have a component named search_detail which has another component inside it named calendar,

SearchDetail_component.html

JavaScript

SearchDetail_component.ts

JavaScript

Calendar.component.ts

JavaScript

I want to access the startdate and enddate on click of the ok button in the search detail page. how can i do?

Advertisement

Answer

Register the EventEmitter in your child component as the @Output:

JavaScript

Emit value on click:

JavaScript

Listen for the events in your parent component’s template:

JavaScript

and in the parent component:

JavaScript

It’s also well explained in the official docs: Component interaction.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement