2016-12-02 4 views
0

ここでは、テーブルにある量のデータを表示しています。私の目標は、私がその行を削除したいチェックボックスを選択するときです。してください、助けてください、私はそれを動作させることはできません。削除する方法checkbxesを使用してテーブルから選択した列を記録します

Htmlcode

<div ng-controller="EmpCtrl"> 
    <table class="table table-hover table-bordered" ng-show="GetDb.length>0"> 
     <tr> 
      <th> 
       <input name="all" type="checkbox" ng-click="selectAllFriends()" /> 
      </th> 
      <th>Id</th> 
     </tr> 
     <tr ng-repeat="ee in GetDb" ng-class="{'success' : tableSelection[$index]}"> 
      <td> 
       <input name="all" type="checkbox" ng-model="ee.checked" ng-true-value="{{ee.id}}" /> 

      </td> 
      <td>{{ee.id}}</td> 
</div> 

Controller.Js

$scope.remove = function() { 
    $scope.deletedIds = []; 
    $scope.GetDb.forEach(function (x) { 
     if (x.checked) { 
      $scope.deletedIds.push(x) 
     } 
    } 
)} 

答えて

0

削除するために、あなたは( 'deletedIds')の別のコピーを保持していない、削除したいものを、それを下の方法で削除してください。

$scope.remove=function(){ 
    $scope.GetDb.forEach(function (x,index) { 
     if (x.checked) { 
      $scope.GetDb.splice(index,1); 
     } 
    } 
} 
+0

ああ、あなたもサーバー側で心を保った後、行く後、所望の詳細を取得するために再び呼び出す簡単な溶液 - である –

+0

あなたがクライアント側で尋ねていると思った。 –

+0

詳細を渡すためにHTTPリクエストを行う必要があり、その方法を実装する必要があります –

0

ここで私は、あなたがDBからの除去の成功の後MVCにそのparamerを渡してやっていたと

<div ng-controller="EmpCtrl"> 
     <table class="table table-hover table-bordered" ng-show="GetDb.length>0"> 
      <tr> 
       <th> 
        <input name="all" type="checkbox" ng-click="selectAllFriends()" /> 
       </th> 
       <th>Id</th> 
      </tr> 
      <tr ng-repeat="ee in GetDb" ng-class="{'success' : tableSelection[$index]}"> 
       <td> 
        <input name="all" type="checkbox" ng-model="ee.checked" ng-true-value="{{ee.id}}" ng-change="delete($index)"/> 

       </td> 
       <td>{{ee.id}}</td> 
    </div> 


$scope.delete = function(index){ 
    delete $scope.GetDb[index].checked; 
    delete $scope.GetDb[index].id; 
}; 
関連する問題