I have a Array (mMemberCount
) in Parent Component and based on the size of this array the child component (Reusable) is attached to Parent component.
<member-template *ngFor="let item of mMemberCount" [title]="item.relation" [memberid]="item.id" (update)="update($event)">
</member-template>
<div class="btn_container">
<button class="button orange" type="submit">Submit</button>
</div>
The child component is as follows
@Component({
selector: 'member-template',
templateUrl: './member-template.component.html',
styleUrls: ['./member-template.component.scss'],
providers: [],
})
export class MemberTemplateComponent implements OnInit {
TAG: string = " MEMBER-TEMPLATE: ";
// Input variables wil be taken from the calling
@Input('title') title: string;
@Input('memberid') memberId: number;
@Output('update')
datasubmit: EventEmitter<string> = new EventEmitter<string>();
sendDataToParent(){
let output = "Tetsing Eventemitter";
this.datasubmit.emit(output);
}
}
The @output('update') is working fine. I want to call this sendDataToParent() of ChildComponent (MemberTemplateComponent) from ParentComponent. I mean when the user tap the button submit of the parent component this sendDataToParent
should call