我有以下 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>
关于javascript - 获取表中单击的行 - AngularJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44589923/