AngularJS - remove selected items according to checkbox

1

How do I get the ids of the selected items from the checkbox (es) to send to the backend and then remove it?

       <a href="">
            **O QUE PASSO POR PARAMETRO PARA A FUNÇÃO? **
            <i class="material-icons" title="Remover" ng-
            click="removeEntry(allEntries)">delete</i>
        </a>


        <tr ng-repeat="entry in allEntries | filter: search as results">


            <td>
                ** OQUE EU PASSO NO MODEL DO CHECKBOX ?**
                <input ng-model="???????" type="checkbox" 
                 id="item-"> 
            </td>
            <td style="max-width: 100px">{{entry.value}}</td>
            <td style="max-width: 100px">{{entry.type}}</td>
            <td style="max-width: 100px">{{entry.date}}</td>
            <td style="max-width: 100px">{{entry.category}}</td>
            <td style="max-width: 100px">{{entry.description}}</td>
        </tr>
    
asked by anonymous 12.02.2017 / 01:48

1 answer

1

angular.module("app", [])
  .controller("ctrl", ["$scope",
    function($scope) {
      $scope.allEntries = [{
        'value': 1,
        'type': 2,
        'date': '01/01/1999',
        'category': 3,
        'description': 'd1'
      }, {
        'value': 10,
        'type': 20,
        'date': '20/01/1999',
        'category': 30,
        'description': 'd20'
      }, {
        'value': 40,
        'type': 50,
        'date': '25/01/1999',
        'category': 60,
        'description': 'd60'
      }];
      $scope.removeEntry = function() {
        angular.forEach($scope.allEntries,
          function(a, b) {
            if (!(typeof a.status == "undefined") &&
              a.status) {
              console.log(a.status);
            }
          });
      };
      $scope.isHas = function() {
        for (let i = 0; i < $scope.allEntries.length; i++) {
          var a = $scope.allEntries[i];
          if (!(typeof a.status == "undefined")) {
            if (a.status) 
            {
              return true;
            }
          }
        }
        return false;
      };
    }
  ]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="app" ng-controller="ctrl">
  <div style="height:18px">
  <a href="" ng-click="removeEntry()" ng-show="isHas()">
    <i class="material-icons" title="Remover">delete</i>
  </a>
  </div>
  <table>
    <tr ng-repeat="entry in allEntries">
      <td>
        <input ng-model="entry.status" type="checkbox">
      </td>
      <td style="max-width: 100px">{{entry.value}}</td>
      <td style="max-width: 100px">{{entry.type}}</td>
      <td style="max-width: 100px">{{entry.date}}</td>
      <td style="max-width: 100px">{{entry.category}}</td>
      <td style="max-width: 100px">{{entry.description}}</td>
    </tr>
  </table>
  <div>
    
12.02.2017 / 02:04