ionic framework - angularjs - filter value between 2 number -


i want ask. i'd search angularjs filter havent found yet solution mine. use angular make android app ionic framework.

i have data price. want filter price range.

ex:

name      type        price item01    fruit       25000 item02    vegetable   50000 item03    vegetable   10000 

i have 2 select box filtering

<select ng-value="fprice">    <option value="">all</option>    <option value="0">0-24999</option>    <option value="25000">25000-49999</option> </select>  <select ng-value="ftype">    <option value="">all</option>    <option value="fruit">fruit</option>    <option value="vegetable">vegetable</option> </select> 

i want if select second value (price) item02 didnt show.

i have code like

<ion-list>     <ion-item ng-repeat="item in items | filter: { type: ftype, price: ??? }">     {{item.name}}<br>     {{item.type}}<br>     {{item.price}}     </ion-item>  </ion-list> 

what code ??? in code? have try still dont find looking for.

thank you. sorry bad english.

you can create custom filter. post example on jsfiddle

in filter can put want.

my custom filter

autodrops.filter('filtercostum', function () {     return function (datas, fprice, ftype) {             console.log(ftype)          var options = [];         angular.foreach(datas, function (data) {                 if(ftype != ""){                 if (data.type == ftype) {                  if(fprice == ""){                                      options.push(data);                      }                     else if(fprice == 0){                             if(data.price >= 0 && data.price <=24999)                             options.push(data);                     }                     else if(fprice == 25000){                         if(data.price >= 25000 && data.price<=49999)                       options.push(data);                     }                     }             }             else{             console.log(fprice)              if(fprice == ""){                                      options.push(data);                      }                     else if(fprice == 0){                             if(data.price >= 0 && data.price <=24999)                             options.push(data);                     }                     else if(fprice == 25000){                         if(data.price >= 25000 && data.price<=49999)                       options.push(data);                     }                     }              });          return options;     } }) 

i call

<div ng-app="autodrops" ng-controller="dropscontroller"> <select ng-model="fprice">    <option value="">all</option>    <option value="0">0-24999</option>    <option value="25000">25000-49999</option> </select>  <select ng-model="ftype">    <option value="">all</option>    <option value="fruit">fruit</option>    <option value="vegetable">vegetable</option> </select>  <div>      <div>         <div ng-repeat="elem in datas | filtercostum: fprice: ftype">         {{elem}}         </div>     </div>     <div> 

link edited


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -