2016-08-23 5 views
0

私は、チェックボックスが選択されているときにテーブルからいくつかの行を隠すテーブルを持っています。最初は、私が事前に計算した数を示しています。私は行を隠す/表示するためにng-showを使用しています。したがって、length関数は合計カウントを返します。ng-show/hide/ifによって隠された行数をカウントします。

<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> 

テーブルの行数を表示する必要があります。チェックボックスが選択されていると、ng-showの隠し行数を削除する必要があります。

角度関数エクスクルー()コントローラ内のプレフィルターDetail

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

     }; 
+0

また、あなたのチェックボックスのコードを追加することができますか? –

答えて

0

$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> 
1
<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--; 
    //... 
} 
+0

ng-repeatでfnを使用することはできません。無限ループで立ち往生する – matrixguy

関連する問題