angularjs - angular price range filter not working -


i have made price range filter, , when checkboxes clicked, want show items have price falling in price range specified checkbox

this following - http://jsfiddle.net/65pyj/

html

<div class="checkbox">     <input type="checkbox" ng-click="includeprice('0,700')" ng-checked=""/> rs 700 , below <br/>     <input type="checkbox" ng-click="includeprice('701,1500')" ng-checked=""/> rs 701 - 1500 <br/>     <input type="checkbox" ng-click="includeprice('1501,3000')" ng-checked=""/> rs 1501 - 3000 <br/>      <input type="checkbox" ng-click="includeprice('3001,5000')" ng-checked=""/> rs 3000 - 5000 <br/>      <input type="checkbox" ng-click="includeprice('5001,100000000')" ng-checked=""/> rs 5001 , above </div> 

in controller, min , maximum of each checkbox array , again min , max of array lower , upper limit

controller

$scope.priceincludes = []; $scope.ranges = [];  $scope.includeprice = function(pricerange) {     var = $.inarray(pricerange, $scope.priceincludes);     if (i > -1) {         $scope.priceincludes.splice(i, 1);         ranges = pricerange.split(',').splice(i, 1);     } else {         $scope.priceincludes.push(pricerange);     }     var arraystring = $scope.priceincludes.join();     var rangearray = arraystring.split(',')     $scope.maxrange = function( rangearray ){         return math.max.apply( math, rangearray );     };     $scope.minrange = function( rangearray ){         return math.min.apply( math, rangearray );     };     $scope.ranges[1] = $scope.maxrange(rangearray);     $scope.ranges[0] = $scope.minrange(rangearray); }  $scope.pricefilter = function(searchresult) {     if ($scope.priceincludes.length > 0) {         if ((parseint(searchresult.fees) >= parseint($scope.ranges[0])) && (parseint(searchresult.fees) <= parseint($scope.ranges[1])))             return;     }     return searchresult; } 

when use

filter:pricefilter 

it returns random results fall out of selected min , max limit.

you supposed return value if condition true. not other way around.

$scope.pricefilter = function(searchresult) {         if ($scope.priceincludes.length > 0) {             if ((parseint(searchresult.fees) >= parseint($scope.ranges[0])) && (parseint(searchresult.fees) <= parseint($scope.ranges[1])))         return searchresult;         } else {         return searchresult;         }     } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -