Home > front end >  How to use child component data in parent component? How to make a binding?
How to use child component data in parent component? How to make a binding?

Time:07-31

For example, we have one field Input, property 'currentNode' in child component and property 'activeElement' in parent component. Every time we change value in Input, it affects property 'currentNode'. And also, of course, parent component contains child component (I mean HTML).

So, I want that every time currentNode changes somehow, it affected activeElement, which's located in parent component.

CodePudding user response:

Add (change)="" method into your Input field. Then Use @Output() to send the event on every change. While you emit currentNode in your parent. your parent function automatically calls then you can update your parent activeElement with the emitting value

click here to see How you can send data to your parent component

  • Related