0

I want to filter my table using select value. In my code below, using input type=text... filter works just fine. But i don't know how to filter using select value.

<div class="columns large-2-5">
    <select name="categorySelector"
            class="selectbox"
            ng-model="search"
            ng-options="category.name for category in categories">
        <option value="">Select Category</option>
    </select>
</div>

<div class="row">
    <input type="text" ng-model="search.name">
    <table class="grid">
       <tbody ng-repeat="image in imageList | filter: { category: search.name }">
         <tr photolistsetting-Directive
            title="{{ image.name }}"
            ref="{{ image.url }}"
            category="{{ image.category }}">
         </tr>
      </tbody>
   </table>
</div>

select list is made of objects. Maybe i can't access an object property ? Thank you.

1 Answer 1

1

Use this:

  <select name="categorySelector"
        class="selectbox"
        ng-model="search.name"
        ng-options="category.name for category in categories">
    <option value="">Select Category</option>
</select>

Edit: Sorry I pointed out incorrect earlier.

Can you post "categories" and "imageList" array here?

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

3 Comments

it selects an object. if i use {{ search.name }} it prints an object. Any ideas how to refer to object property in filter ?
Have a look at this, its similar to your code and working: plnkr.co/edit/xf8UTpn2eBx6H1muMnfz?p=preview
accidentally moved one div out of scope. damn i'm fool. Your example is good. Thanks :)

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.