Tanzeel
Tanzeel

Reputation: 5008

How to pass data from child component to parent [Angular]

I'm learning Angular. I want to see how a Child component Output data to Parent component. I've gone through some articles and documentation then created a minimal program. I'm able to send data from Parent to Child successfully but not the vice-versa. I'm not getting any error but I'm not getting the values also. Can you please see my code and correct me. Here is my stackblitz.

Upvotes: 0

Views: 113

Answers (2)

Himanshu Singh
Himanshu Singh

Reputation: 2165

working demo : demo

You have missed to place {{ChildCurrentVal}} in app.component.html and not only that your child component will return value only when your child receive value from parent otherwise it return undefined.

Upvotes: 1

Adrian Brand
Adrian Brand

Reputation: 21658

It is working, you just don't show the value of ChildCurrentVal anywhere.

Put

{{ChildCurrentVal}}

In the template somewhere

Upvotes: 3

Related Questions