![](/img/trans.png)
[英]How to get value of a <td> onclick to an other <td> of a same row?
[英]Get value of a <td> onclick to an other <td> of the same row with Angular
我想获得一个数据单元格的值<td>
如果我点击到其他<td>
同一行的。
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country | uppercase }}</td>
</tr>
解决它的一种方法是例如http://jsfiddle.net/L60L3gv9/
$scope.getValueOfTD = function(x){
alert(x.Name);
}
但在我的情况下,我的数据单元之间没有链接。 有没有办法用标准函数来获得这个值?
$scope.getValueOfTD = function(){
}
任何解决方案都没问题
您可以在tr
上使用ng-click
:
HTML:
<table>
<th>Column1</th>
<th>Column2</th>
<tr ng-repeat="x in names" ng-click="getValueOfTD(x)">
<td>{{ x.Name }}</td>
<td>{{ x.Country | uppercase }}</td>
</tr>
</table>
JS:
$scope.getValueOfTD = function (user) {
console.log(user.Name);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.