簡體   English   中英

單擊ng-repeat后刪除按鈕“刪除”

[英]Delete button “delete” after clicking in 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;
}

我刪除所有元素的代碼只需要刪除一個我選擇的代碼

嘗試這個

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);
   }
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM