Good afternoon guys, i have the following structure:
parent.html
<child-component>
<ng-template let-dataSource="dataSource" let-displayedColumns="dc">
<mat-table class="cruds-table" [dataSource]="dataSource" matSort fusePerfectScrollbar>
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header>Nome</mat-header-cell>
<mat-cell *matCellDef="let crud">
<p class="text-truncate" (click)="clica()">{{crud.name}}</p>
</mat-cell>
</ng-container>
[...]</ng-template>
</child-component>
child.html
<ng-container *ngTemplateOutlet="contentTable;context:{dataSource: dataSource, dc: displayedColumns}"></ng-container>
child.ts
clica(){
alert('clicked');
}
when I click on it, the function is triggered on the parent component, i know i can use View to get the child component and use as child.clica(), but i have many functions and i would prefer to bind all the events inside of this container to the child component.
Is there any way to do this?
Sorry if it's confusing, it's complicated to explain. Thanks!