javascript - Filter results from API with angularjs -
i receiving data api in angular , trying filter result hotels min_price less example 50$!
$http.get($rootscope.baseurl + 'api/hotels/', { params: { page_size: $scope.page_size, page: $scope.page, goingto: goingto, ordering: $scope.sortby, star: $scope.filter.star, min_price: ???? }}).then( function(data, status, headers, config) { $scope.hotels = data.data.results; $scope.count = data.data.count; $scope.loading = false; pageservice.setcontentready(); }, function(data, status, headers, config) { $scope.loading = false; pageservice.contentstatus = 'ready'; } );
how show hotels under 50$ ?
find below updated code
$http.get($rootscope.baseurl + 'api/hotels/', { params: { page_size: $scope.page_size, page: $scope.page, goingto: goingto, ordering: $scope.sortby, star: $scope.filter.star, min_price: 50 } }).then( function(data, status, headers, config) { $scope.hotels = data.data.results; $scope.hotels = $scope.hotels.filter(function(hotel){ return hotel.min_price < 50}); //filter hotels $scope.count = data.data.count; $scope.loading = false; pageservice.setcontentready(); }, function(data, status, headers, config) { $scope.loading = false; pageservice.contentstatus = 'ready'; } );
Comments
Post a Comment