Skip to content
Advertisement

How to pass data from child to parent?

I need to pass one variable, that is inside my child component, to parent page. This variable that I am trying to pass, is the array result of Barcode Scanner.

And I need to pass it to parent to send to API.

childComponent.ts

JavaScript

parentComponent.ts

JavaScript

Advertisement

Answer

Here is an example stackblitz project to test parent-child data transfer, using @Input() and @Output()mechanism

JavaScript

here is the parent component html called child

JavaScript

and event bindin like that

JavaScript
Advertisement