Reputation: 297
I'm getting some JSON data from a WordPress site to my ionic app, I'm filtering the data receipts and it works successfully, for example I'm getting the "price" field:
<label class="item item-input"> <input type="text" size="17" placeholder="Prix Min" ng-model="prixmin" ng-change="showSelectValue(prixmin)"> </label>
<ion-item class="item item-thumbnail-left item-text-wrap item-icon-right" ng-repeat="post in recent_posts | filter:{ custom_fields: { trav_accommodation_avg_price:prixmin}}">
My problem is that I don't want to get posts with exactly the value of the price but I want to get posts they have values greater than this value.
Thank you.
Upvotes: 0
Views: 42
Reputation: 7911
You could create a custom filter that takes the price (here prixmin
) as input and gives you the only items having price more than that. Something like:
.filter("priceGreaterThan", function() {
return function(arr, price) {
return arr.filter(function(obj) {
return Number(obj.custom_fields.trav_accommodation_avg_price) > Number(price)
}
})
})
And, use it in your ng-repeat
like,
ng-repeat="post in recent_posts | priceGreaterThan: prixmin"
Upvotes: 2