Anirban Anirban - 1 month ago 11
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="f.name for f in state_select | orderBy:'name'"></select>
</div>


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>{{user.fullname}}</td>

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

<td>{{user.district_name}}</td>

<td>{{user.state_name}}</td>

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

</tr>



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

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

filter:{state_name:state_select.value}