I Need to Implement simple Excel Like Filer for table using angulajs(v.1) I\'m getting stuck please help me, I have added my code snippet below. I want to show filtered Data in
Change ng-model
to have one dummy variable lets say emp.status
whose value will be either true
or false
based on clicking checkbox.
HTML country dropdown
-
Controller :
var countrySet = [];
$scope.employees=employees;
$scope.showResults=employees;
function _setFilterData(){
var emplList = angular.copy(employees);
$scope.showResults = emplList.filter(function(v, idx){
return countrySet.includes(v.Country)
});
}
$scope.yourFunction = function(checkBoxStatus, country){
var index = countrySet.indexOf( country );
if(checkBoxStatus && index === -1 ) {
countrySet.push( country);
}else{
countrySet.splice( index, 1 );
}
_setFilterData();
console.error(checkBoxStatus, country, countrySet);
}
Please check plunker for functionality : https://plnkr.co/edit/aXhvM0?p=preview
NOTE: Never mind CSS on plunker