0

In my application, I have used pricing slider. When I change minimum and maximum value of pricing slider, I need to filter based on the range. In angularjs, how to do this one. Can you please any one help me.

$scope.min_price = 0;
$scope.max_price = 10000;

$scope.priceFilter = function (hotel) {
  console.log(hotel.AvailableRoom[0]);
  if(hotel.AvailableRoom[0] !== null && hotel.AvailableRoom[0].HotelRoom.Price != null){
    console.log(hotel);
    return (hotel.AvailableRoom[0].HotelRoom.Price.Amount >= $scope.min_price && hotel.AvailableRoom[0].HotelRoom.Price.Amount <= $scope.max_price);
  }
  else if(hotel.AvailableRoom.HotelRoom[0].Price != null) {
    console.log(hotel);
    return (hotel.AvailableRoom.HotelRoom.Price.Amount >= $scope.min_price && hotel.AvailableRoom.HotelRoom.Price.Amount <= $scope.max_price);
  }
};

and I have added filter:priceFilter in ng-repeat. It is called whenever reload page. But I want to call this one when price range is changed.

<div id="rangeslider" range-slider min="0" max="1000" model-min="min" model-max="max" ></div>

above is pricing slider.

0

2 Answers 2

1

Have you tried adding an ng-mouseup (https://docs.angularjs.org/api/ng/directive/ngMouseup) to your rangeslider div and calling your priceFilter method from there?

Sign up to request clarification or add additional context in comments.

Comments

0

i have same problme.. and i finding the mouse-release event, but still not got exact.

but i solve this problem by $watch and it's just slow but working properly..

$scope.$watch( '[demo7.maxPrice, demo7.minPrice]', function() {
    $scope.filterByPriceRange();
});


$scope.filterByPriceRange = function() {
    $rootScope.filteredRooms = [];
    angular.forEach(
        $rootScope.filteredRoomsByPricingType,
        function(availableRoom) {
            for (i in availableRoom.roomPricings) {
                if (availableRoom.roomPricings[i].price >= $rootScope.demo7.minPrice
                && availableRoom.roomPricings[i].price <= $rootScope.demo7.maxPrice
                && availableRoom.roomPricings[i].pricingType.pricingType == $rootScope.pricingType) {
                $rootScope.filteredRooms
                .push(availableRoom);
            }
        }
    });
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.