【发布时间】:2017-01-15 03:44:03
【问题描述】:
我有一个用 ng-repeat 填充的表。单击该行时,我正在使用 ng-click 检索与对象相关的数据。该表填充了一个 json 文件。单击选定的行时如何隐藏表格的所有其他行?
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
</thead>
<tbody style="cursor: pointer" ng-cloak> <!--When the row is clicked, I want to hide all other rows except the clicked one.-->
<tr ng-repeat="person in people" ng-click="getSelected(person);">
<td>{{ person.firstName }}</td>
<td>{{ person.lastName }}</td>
<td>{{ person.age }}</td>
</tr>
</tbody>
</table>
<script>
angular.module("App", []).controller("MainController", function ($scope) {
$scope.people = peopleData;
$scope.getSelected = function (person) {
$scope.selected = person;
};
});
</script>
【问题讨论】:
-
对这个问题投反对票?
标签: javascript html angularjs