简体   繁体   中英

angularJs filter using ng-repeat and select

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM