Anirban Anirban - 1 year ago 68
Javascript Question

filter on basis of selected option Angular

I have a select list which populates states name of united states

<div class="form-group">
<select ng-model="state_select" ng-options=" for f in state_select | orderBy:'name'"></select>

Now I have a table which is populated as follows:-

<tr dir-paginate="user in users|orderBy:['state_name','fullname']|filter:{user.state_name:state_select.value}|itemsPerPage:10" pagination-id="byState">

<td> <img src="{{user.party_name}}" style="max-height: 10%;max-width: 10%;"/> </td>


<td > <img src="{{user.chamber_type}}" style="max-height: 8%;max-width: 7%;"/>{{user.chamber_name}} </td>



<td> <button type="button" class="btn btn-primary">View Details</button></td>


I just want those entries to be selected where the state name is same as the above select option value. I wrote the filter part but it is giving me some errors. I just want filter on the basis of state name only. Can some one please help me.

Answer Source

You wrote your filter wrong. Change your filter to following.