0
votes

I am using angularjs smart-table to display data on a web page. I am using certain fields to filter the data and display. There is also pagination on the table. Everything is working perfect. I have a checkbox on the table header for selectall functionality and another checkbox at each row level. I have to clear checkboxes (if they are checked) whenever there is any change in search criteria. I cannot think of how I can do it. Any ideas on how I can achieve this ?

1
ng-change="myFunc()"?gr3g
Thank you for the response. It worked.rednerus

1 Answers

1
votes
.controller('MyController', ['$scope', funciton($scope){

$scope.data = {}; // probably a JSON object

$scope.reset = function(){
  scope.data.row.forEach(function(el){
     el.checkbox = false;
  });
};

}])

<input type="text" ng-change="reset()"/>

<div ng-repeat="item in data track by $index">
   <!-- Items -->
</div>

Note: You can also put this inside a directive, wich is the fancy of angular.

.directive('clear', function(){
  return {
     restrict : 'A',
     require : 'ngChange',
     link : function(scope, element, attrs, ngChangeCtrl){
         //Do your stuff with ngChange controller 
     }
  };
});

<input type="text" clear/>