Currently, I am in the process of implementing a filtering system using checkboxes. Within my geojson data, there is a property called "status" which can have values like:
status : "Act 3Q99"
or
status : "Fut 3Q99"
My objective is to filter based on either "Act" or "Fut". Below is the code snippet for my filter:
function StatusFilter() {
return function (territorySubdivisions, typeFilter) {
var filtered = [];
angular.forEach(territorySubdivisions, function (subdivision) {
if (typeFilter.active == true && typeFilter.future == true) {
filtered.push(subdivision);
}
else if (typeFilter.active == true && typeFilter.future == false && subdivision.properties.status == subdivision.properties.status.indexOf('Act') != -1) {
filtered.push(subdivision);
}
else if (typeFilter.future == true && typeFilter.active == false && subdivision.properties.status == subdivision.properties.status.indexOf('Fut') != -1) {
filtered.push(subdivision);
}
});
return filtered;
};
};
This is the approach I have attempted:
subdivision.properties.status.indexOf('Act') != -1
Unfortunately, the above code is not yielding the desired results. In order to isolate any potential conflicts, I have included additional code for sorting and filtering in a working Plunker example.
<div class="col-xs-3">
<div class="checkbox checkbox-success checkbox-inline">
<input type="checkbox" id="active-checkbox-filter" ng-model="vm.typeFilter.active" ng-change="vm.statusActive('active')">
<label for="active-checkbox-filter"> Active </label>
</div>
</div>
<div class="col-xs-3">
<div class="checkbox checkbox-success checkbox-inline">
<input type="checkbox" id="future-checkbox-filter" ng-model="vm.typeFilter.future" ng-change="vm.statusFuture('future')">
<label for="future-checkbox-filter"> Future </label>
</div>
</div>