Javascript 如何为角垫表上的行添加onClick事件,然后转到其他页面?
我的问题是如何在特定行上添加单击事件,并转到下一个包含单击行的值的表单。我现在有点困惑Javascript 如何为角垫表上的行添加onClick事件,然后转到其他页面?,javascript,html,css,angularjs,Javascript,Html,Css,Angularjs,我的问题是如何在特定行上添加单击事件,并转到下一个包含单击行的值的表单。我现在有点困惑 项目名称 {{element.itemname} 类别 {{element.category} 量 {{element.quantity} 尝试像这样单击发送值 <ng-container matColumnDef="itemname"> <th mat-header-cell *matHeaderCellDef> ITEM NAME </th>
项目名称
{{element.itemname}
类别
{{element.category}
量
{{element.quantity}
尝试像这样单击发送值
<ng-container matColumnDef="itemname">
<th mat-header-cell *matHeaderCellDef> ITEM NAME </th>
<td mat-cell *matCellDef="let element">
<ng-container ng-click="passValue(element.itemname)">
{{element.itemname}}
</ng-container>
</td>
</ng-container>
然后你可以用其他任何形式的值。
请要求任何澄清。您的问题有点混乱,您想从表中获取值并重定向到另一页??还是同一个页面不同的表单?@BlizZard我的问题是我想单击一行,然后将它们的值传递给不同的表单我不确定如何在typescript中实现js codetypescript只是js的一部分,所以所有js代码也都在typescript中工作。所以,只要将其添加到.ts文件中,它将工作我更新了我的代码,我错过了行区域,我需要获得整行的值,并将这些值传递给一个新的表单
<ng-container matColumnDef="itemname">
<th mat-header-cell *matHeaderCellDef> ITEM NAME </th>
<td mat-cell *matCellDef="let element">
<ng-container ng-click="passValue(element.itemname)">
{{element.itemname}}
</ng-container>
</td>
</ng-container>
clickedValue:any;
passValue(val:any){
this.clickedValue = val;
console.log(clickedVal);
}