[英]Get row clicked in a table - AngularJS
我有以下HTML代码。 这是一个表,用于从costList中获取项目列表,并将其显示在不同的行中。 我希望在单击行时显示项目值。 如何在Angular中实现它。 先感谢您。
<table>
<tr ng-click = "displayItem()" ng-repeat = "item in costList">
<td>{{item}}</td>
</tr>
</table>
ng-click="displayItem(item)"
或者您可以将项目存储在displayItem中。
$scope.displayItem = function (item) { $scope.currentItem = item; }
<div>{{currentItem}}</div>
<table>
<tr ng-click = "selectedItem = item" ng-repeat = "item in costList">
<td>{{selectedItem}}</td>
</tr>
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.