I'm trying to append a button to an angular table.
It shows the button but when a click on it, it doesn't fire the event.
This is my table:
<table mat-table [dataSource]="GetGridData()">
<!-- Rest removed for brevity.. -->
<ng-container matColumnDef="Products">
<th mat-header-cell *matHeaderCellDef> Products </th>
<td mat-cell *matCellDef="let element">
<button mat-raised-button (click)="OnGetAllProducts(element.CategoryId)">See all products</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="GetGridHeader()"></tr>
<tr mat-row *matRowDef="let row; columns: GetGridHeader();"></tr>
</table>
And this is what I've got on my ts:
export class DashboardComponent {
// Rest of code removed for brevity.
// Row's events.
//--------------
OnGetAllProducts(categoryId: number) {
alert("Listed");
}
}
And this is my model:
export class Category {
public CategoryId: number;
public CategoryName: string;
}
See all products
button visible in UI?