i'm using rangle slider on my project. i want to filter the ng-repeat on sliding of range slider. i want to filter the data on the price. my code html:-
<range-slider min="slider.min" max="slider.max" step="slider.step" lower-value="slider.min" upper-value="slider.max"></range-slider>
<div ng-repeat="data in data|filter:rangeFilter()">
Property: {{data.name}}
price: {{data.price}}
</div>
controller:-
$scope.data = [{
name : hoarding1,
price : 50000
},
{
name : hoarding2,
price : 50000
},
{
name : hoarding3,
price : 50000
}
]
$scope.slider = {
step : 10000,
min : Math.min.apply(Math,$scope.data.map(function(item){return item.price;})),
max : Math.max.apply(Math,$scope.data.map(function(item){return item.price;}))
}
$scope.rangeSlider = function (){
return function( items, rangeInfo ) {
var filtered = [];
var min = parseInt(rangeInfo.min);
var max = parseInt(rangeInfo.max);
// If time is with the range
angular.forEach(items, function(item) {
if( item.price >= min && item.price <= max ) {
filtered.push(item);
}
});
return filtered;
};
this is not worked for me. Please help me :-(