Reputation: 737
Angular v6.
Have a Parent component which has a send button.
A Card Component in which multiple inputs are present list/ comments/checkbox etc.
Parent component loops and calls the card component.
Example:
<div>
<div *ngFor="3 times">
<card-component></card-component>
</div>
</div>
Is there any way without clicking any thing to get the values of the child component while pressing the send button on the parent.
Eventemitter requires an action like a click on the child, but is there any way to get the child component details when clicking the send button on the parent.
Upvotes: 1
Views: 57
Reputation: 3574
In parent component ts, use:
@ViewChild(ChildComponent) child: ChildComponent;
And use it to access its properties and methods, after the child component gets properly rendered:
console.log(this.child.your_child_variable);
Upvotes: 1