预信息
我尝试将管理员和客户分开在不同的阶段或 View 中。
这样,管理员可以在将表发布给客户之前对其进行修改。
问题 在表格 -> td 中有按钮来控制暂存、释放(显示)或恢复(隐藏)?
所以基本上我想做的是,检查的每个表都可以显示在管理员和客户中。如果未选中,则数据仅向管理员显示。
目前,代码禁用整个表体而不是 1 行。
有什么方法可以只选中或取消选中 1 行吗?
谢谢你的建议。
$scope.showDiv = isAdmin();
$scope.toggleShowDiv = function () {
$scope.showDiv = !isAdmin()&isAdmin();
console.log('fired');
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<thead>
<tr>
<th style="width: 80px">foo1</th>
<th style="width: 80px">foo2</th>
<th style="width: 200px">foo3</th>
<th>foo4</th>
<th>foo5</th>
<th>foo6</th>
</tr>
</thead>
<tbody class="auction-group" ng-repeat="a in foos" ng-if="showDiv">
<tr>
<td>abcd1</td>
<td>abcd1</td>
<td>abcd1</td>
<td>abcd3</td>
<td>abcd4</td>
<td>abcd5</td>
//is admin - show only to admin
<td ng-if="::isAdmin()">
<input type="checkbox" ng-click="toggleShowDiv()" />
</td>
</tr>
</tbody>
最佳答案
将你的第一个 ng-if 放在 ng-repeat 之外
<div ng-if="showDiv">
<tbody class="auction-group" ng-repeat="a in foos">
</div>
第二个 ng-if 应该是这样的,
<td ng-if="isAdmin()">
<input type="checkbox" ng-click="toggleShowDiv()" />
</td>
关于javascript - 如何结合 ng-if 、 ng-click 和 ng-show 并一起使用它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46146882/