我在我的项目中使用 rangle 滑块。我想在范围滑块滑动时过滤 ng-repeat。我想过滤价格数据。我的代码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>
控制器:-
$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;
};
这对我不起作用。请帮我 :-(