1

I am using Angular Table which displays records from a MySQL using ng-repeat. THe last column is a checkbox column. The problem is that when navigating between pages (pagination), the state of which the checkbox was loaded with persistent. How do I keep the state between the pages (if i checked/unchecked an item)?

<tr ng-repeat="data in filtered = (list | filter:search | 
filter:{manufacturer:by_manufac} | 
filter:{errorStatus:by_errorStatus} | 
orderBy : predicate :reverse) | 
startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">

<td>
    <input type="checkbox" name="checkedin" ng-model='checkedin' 
    ng-change='processForm(data)' ng-checked="data.Locked==1"/>
</td>
</tr>

In the controller:

$scope.processForm = function(checkedindata) {
      $http.post('ajax/setItems.php', { data : checkedindata })
    };
necross
  • 147
  • 2
  • 11

1 Answers1

1

For those interested in a solution: in the controller, simply update the value of the $scope as such:

   $scope.processForm = function(post_data) {
        for(i=0; i<$scope.filtered.length; i++) {
          if($scope.filtered[i]['productID'] == post_data['productID']){
              $http.post('ajax/setItems.php', { id : post_data['productID'], operation: !post_data['Locked'] })
              $scope.filtered[i]['Locked'] = !$scope.filtered[i]['Locked'];
              i=$scope.filtered.length;
          }
        }
    };
necross
  • 147
  • 2
  • 11