DawnZHANG DawnZHANG - 10 months ago 52
AngularJS Question

Can I change AngularJS's dirpagination filter from input box to select box?

I've been messing with the AngularJS's dirpagination library, please refer to link:

see code demo at:

I'm wondering, can I change the input box to a select box and get the same function. Eg. I'm filtering some names, but the names can only be chosen from the select box and the content will be filtered according to the input from the select box.

I have tried to achieve this by do the following:

function callFilter(Name) {
document.getElementById("search").value = Name;

<span style="float:right;">
<select style="height: 30px;" onchange="callFilter(this.value);">
<option value="All_Names" selected>Names</option>
<input ng-model="q" id="search" class="form-control" value="" type="hidden">
<input value="10" class="form-control" ng-model="pageSize" type="hidden">

By doing this, I managed to manipulate the hidden input box, however, the value changed in input box won't take actual action to filer my content.
What should I do? Thanks in advance!

Answer Source

Check code for dropdown, and demo here

<select ng-model="q" class="form-control">
     <option value='' Selected>Select</option>
     <option value="meal 1">Meal 1</option>
     <option value="meal 2">Meal 2</option>
     <option value="meal 3">Meal 3</option>