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.
Add a comment
|
2 Answers
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
Tanzeel
Yes Himanshu, I realized that. Such a silly mistake. I'm new to Angular and web development.
Himanshu Singh
@Tanzeel No problem, glad to help.
Tanzeel
Can you please look into this: stackblitz.com/edit/angular-ksdqyr
Himanshu Singh
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)">