Snippet of Code
//controller
$scope.filterByCategory = function (wine) {
return $scope.filter[wine.search_by_item] || noFilter($scope.filter);
};
$scope.filterByLocations = function (w) {
var chambers_location = [];
for(var i=0; i<w.chambers.length; i++) {
chambers_location = w.chambers[i].chamber_location_name;
}
return $scope.filter[chambers_location] || noFilter($scope.filter);
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<!-- filter with checkbox options -->
<h3 class="panel-title">Location</h3>
<ul>
<div ng-repeat="cat in getCategories()">
<label>
<b> <input type="checkbox" class="doctor_checkbox" ng-model="filter[cat]"/> <span ng-if="cat!=0"><% cat %></span><span ng-if="cat==0">Others</span></b>
<span >(<% (names | filter:cat).length %>) </span>
</label>
</div>
</ul>
<h3 class="panel-title">Areas</h3>
<ul>
<div ng-repeat="locations in getLocations()">
<label>
<b> <input type="checkbox" class="doctor_checkbox" ng-model="locations" ng-if="locations!=null"/> <span ng-if="locations!=null"><% locations %></span></b>
<span ng-if="locations!=null">(<%(names | filter:locations).length%>) </span>
</label>
</div>
</ul>
<!-- ng-repeat with filtered value -->
<div class="content-area-article content-area" ng-if="w.check_subscription == 1" ng-repeat="w in filtered=(names| filter:filterByCategory | filter:filterByLocations)">
<!-- codes will go here -->
</div>
Issue with filterByCategory() and filterByLocations(): The two methods are not functioning properly when called within the same ng-repeat. However, individually, they work perfectly when one of them is commented out from the controller.
Seeking guidance on resolving this problem effectively.