Search code examples
javascriptangularjsselectfilterng-options

How to add filter to <select> without <ng-options> in Angular JS?


I have a select statement

<select ng-model="selectedItem" ng-change="onChange()">
        <option id="{{item.toLowerCase()}}" ng-repeat="item in someArray">{{item}}</option>
    </select>

and want to apply a filter on the options to show a different value in the dropdown. Any ideas?

When using ng-options it was easy (see below), but now I can't seem to get it working.

<select
ng-options="item as (item | filterThatIWant) for item in someArray
ng-model="selectedItem"
ng-change="onChange()>
</select>

Basically I just need the equivalent of the above. without the ng-options.

Thanks


Solution

  • Its the same as ng-option

    <select ng-model="selectedItem" ng-change="onChange()">
        <option id="{{item.toLowerCase()}}" ng-repeat="item in someArray | filterThatIWant">{{item}}</option>
    </select>