Is it possible to pass a variable of a component A, in the (onclick)
on an element in component B like below ?:
Component B:
<comp-A (click)="NodeClicked({{index}})"> </comp-A>
Where index
is a variable of the component A.
Is it possible to pass a variable of a component A, in the (onclick)
on an element in component B like below ?:
Component B:
<comp-A (click)="NodeClicked({{index}})"> </comp-A>
Where index
is a variable of the component A.
If you would like to pass the variable from the child (Comp-A) into the parent component (Comp-B) I would suggest using the Event Emitter. An example can be viewed at the bottom of the page.
When a button is clicked from within the child the event will emit to the parent and you can use that data as desired from there.