计算 ng-show/hide/if 隐藏的行数

Count rows hidden by ng-show/hide/if

我有一个 table,它会在选中复选框时从 table 中隐藏一些行。最初它显示我预先计算的计数。我正在使用 ng-show 连续 hide/show。所以长度函数仍然是 returns 总计数。

<input type="checkbox" ng-model="isRChecked" id="chck3" ng-change="ExcludeRChecked();"><label for="chck3">Exclude R</label>


<div>{{Detail.length}} Rows in Table</div>
<tbody>
  <tr ng-repeat="x in Detail" ng-show="excludeR(x.ID)">
    <td colspan="1">{{x.feature}}</td>
    <td colspan="1" ng-click="test(x.ID)">{{x.ID}}</td>
    <td colspan="1">{{x.Log}}</td>
  </tr>
</tbody>

我必须在 table 中显示行数。因此,选择复选框时,应删除NG-Show的隐藏行计数。

angular 函数 ExcludeR()

 $scope.excludeR=function(item){
            if($scope.isRChecked===false)
                return true;
                for(x in $scope.R){
                    if($scope.R[x]===item)
                    {                           
                        return false;
                    }
                }
                return true;

        };

控制器中的预过滤器 Detail

$scope.filteredDetail = $scope.Detail.filter(x => excludeR(x.ID))

<div>{{filteredDetail.length}} Rows in Table</div>
<tbody>
  <tr ng-repeat="x in filteredDetails track by x.ID ">
    <td colspan="1">{{x.feature}}</td>
    <td colspan="1" ng-click="test(x.ID)">{{x.ID}}</td>
    <td colspan="1">{{x.Log}}</td>
  </tr>
</tbody>
<div>{{visibleDetailsCount}} Rows in Table</div>
<tbody>
  <tr ng-repeat="x in Detail" ng-show="excludeR(x.ID)">


$scope.excludeR(param){
   //...
   condition?$scope.visibleDetailsCount++:$scope.visibleDetailsCount--;
   //...
}