Question:I’ve created a button whenever I click on it, it passes all values to this empty object ‘product’. I’m trying to emit this object to the child component, so I can push it inside of the product empty array.
// another component (child)
Answer:If you want to understand how things work in Angular, I suggest following the Angular tutorial.
But here’s a simple example of how you can communicate between components.
Items List Component
The parent is fetching the data through a service and passes it to the items list component through an input. The items list component emits an event when the
Add Productbutton is clicked and sends the result to the parent. The parent is responsible to distribute the selected products to the cart component.
If you have better answer, please add a comment about this, thank you!