Angular 角垫工作台-获取单击事件工作

Angular 角垫工作台-获取单击事件工作,angular,angular-material2,Angular,Angular Material2,我想在我的Angular应用程序中选择我的mat表的一个项目(行)。因此,我使用的是有角度的材质。我想我不知道添加(单击)-事件的正确位置,或者我必须以另一种方式添加?谢谢你的帮助 <div class="table-container mat-elevation-z8"> <mat-table #table [dataSource]="dataSource" matSort> <ng-container matColumnDef="item_id"&

我想在我的Angular应用程序中选择我的mat表的一个项目(行)。因此,我使用的是有角度的材质。我想我不知道添加(单击)-事件的正确位置,或者我必须以另一种方式添加?谢谢你的帮助

<div class="table-container mat-elevation-z8">
  <mat-table #table [dataSource]="dataSource" matSort>

    <ng-container matColumnDef="item_id">
      <mat-header-cell *matHeaderCellDef mat-sort-header> ID </mat-header-cell>
      <mat-cell *matCellDef="let item"> {{item.id}} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="item_name">
      <mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
      <mat-cell *matCellDef="let item" (click)="onSelect(item)"> {{item.name}} </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
  </mat-table>
</div>

身份证件
{{item.id}
名称
{{item.name}
这个例子不起作用。

就这样试试吧

<ng-container matColumnDef="position">
  <mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
  <mat-cell *matCellDef="let element" (click) = "click('aaa')" > {{element.position}} </mat-cell>
</ng-container>

不
{{element.position}


单击表格的第一列

谢谢!太快了!警报也在我的应用程序中运行。但不是我的其他功能。但肯定还有另一个问题。我试着自己解决它。谢谢但是如何将鼠标图标从箭头改为手形呢。你知道吗?@dafna将元素的css游标更改为这个
{cursor:pointer;}
工作!谢谢!:)