2016-12-22 13 views
0

ng-repeatでデータを表示しています。ボタンがあります。アイテムを削除します。 アイテムを削除した後、このボタンは削除したアイテムに対してのみ消滅しなければなりません。ng-repeatをクリックした後、「削除」ボタンを削除します

<tr ng-repeat="paymentinfo in paymentList | filter:keyword | filter:money | filter:getdate | filter:{state: 'archived'}: archived.state ? true : false"> 
    <td id="outmouse"> 
    <ul style="list-style: none;" class="gt-reset"> 
     <li class="dropdown changecoursename"> 
     <a class="dropdown-toggle" data-toggle="dropdown"> 
      <span class="tableOperation norlmalstate">Open Course</span> 
      <span class="tableOperation openedstate">more options</span> 
      <b class="caret"></b> 
     </a> 
     <ul class="dropdown-menu"> 
      <li><a class="tableOperation" ng-click="paymentRemarks()">Remarks</a></li> 
      <li><a class="tableOperation" ng-click="paymentReturn(paymentinfo)">Return</a></li> 
      <li ng-switch on="paymentinfo.state"> 
      <div ng-switch-when="archived" class="archived__state">{{paymentinfo.state}}</div> 
      <a ng-switch-default class="tableOperation" ng-click="paymentDelete();">{{deletebtn}}</a> 
      </li> 
     </ul> 
     </li> 
    </ul> 
    </td> 
</tr> 

あり、私はすべての要素の削除

<li ng-switch on="paymentinfo.state"> 
    <div ng-switch-when="archived" class="archived__state">{{paymentinfo.state}}</div> 
    <a ng-switch-default class="tableOperation" ng-click="paymentDelete();">{{deletebtn}}</a> 
</li> 

私のJS

$scope.datas = [{ 
    date: '06-12-2016', 
    name: 'Pinao Class', 
    state: 'archived', 
    remark: 'remarled', 
    amount: 101, 
    id: 21 
}, { 
    date: '15-04-2016', 
    name: 'drivers Class', 
    state: 'notarchived', 
    remark: 'remarled', 
    amount: 102, 
    id: 22 
}]; 
$scope.paymentList = $scope.datas; 

$scope.deletebtn = "delete"; 

$scope.paymentDelete = function() { 
    $scope.www = true; 
    $scope.deletebtn = false; 
} 

私のコードは、私が

+0

その要素に関連する一意のIDを渡し、それに基づいて削除するだけです –

+0

例を挙げることはできますか? –

+0

http://jsfiddle.net/oymo9g2f/2/ –

答えて

0

この

を試し選ぶ1のためだけの削除必要削除する必要がある場所
ng-click="paymentDelete(this.paymentinfo);">// pass current object to delete function 

$scope.paymentDelete = function (paymentinfo) { 
     $scope.www = true; 
     var index = $scope.paymentList.indexOf(paymentinfo); 
    if (index > -1) { 
    $scope.paymentList.splice(index, 1); 
    } 
} 
+0

要素を削除していますが、ページ上の別の要素はボタン「削除」をfalseに変更します。彼らは値 "削除"を持っている必要があります –

+1

削除する$ scope.deletebtn = false;関数から –

関連する問題