0

I have a select box with some options to filter. I want to filter by two different fields cities and categories:

HTML:

   <select ng-options="c.id as c.name  for c in categories" class="form-control" name="categories" ng-model="categoriesFilter">
     <option value="">All</option>
   </select>

<select ng-options="o.id as o.name  for o in cities" class="form-control" name="cities" ng-model="citiesFilter">
  <option value="">All</option>
</select>

JS:

$scope.categories = [
    {name : "Private", id : 2},
    {name : "Buisness", id : 1},
    {name : "Deleted", id : 3}
];

I filter like this:

<tr ng-repeat="cust in customers | filter : {city:citiesFilter|| 
undefined} | filter : {typeCust: categoriesFilter|| undefined} | filter : 
{deleted: categoriesFilter}">

Here is the full example: jsFiddle

2

1 Answer 1

0

You need to chain filters

<tr ng-repeat="cust in customers | filter: {city: citiesFilter || undefined} | filter: { typeCust: categoriesFilter || undefined}">

Full fiddle: https://jsfiddle.net/vaf031mr/16/

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

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.