I am taking data from table and display as multi check checkboxes.My checkboxes when checked pushes data on array for that particular checkbox.But when unchecked ,the respective data should be removed from the array.How can I achieve this?
HTML:
<div ng-repeat="data in filters.status" > <label class="Form-label--tick"> <input type="checkbox" value="data.id" id="status" ng-model="status" class="Form-label-checkbox" ng-change="IfCheck(data.id,status)" > <span class="Form-label-text"> {{data.status}}</span> </label> </div>
Javascript:
<script> $scope.IfCheck = function (data, check) { if (check) { status.push(data); $scope.checkedData[0].status = status; } else { var index = $scope.status.indexOf(data); $scope.status.splice(index); } }; </script>