0

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.

2 Answers 2

3

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

Put

{{ChildCurrentVal}}

In the template somewhere

Sign up to request clarification or add additional context in comments.

Comments

1

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.

4 Comments

Yes Himanshu, I realized that. Such a silly mistake. I'm new to Angular and web development.
@Tanzeel No problem, glad to help.
Can you please look into this: stackblitz.com/edit/angular-ksdqyr
Your parent.component.html <child (outputToParent)="GetOutputVal($event)"></child> should have this. And your child.component.html is missing ngModel and ngModelChange like this: <input type="text" [(ngModel)]="value" (ngModelChange)="sendToParent($event)">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.