Bennie Glarilso
Bennie Glarilso

Reputation: 1

how to filter table data using angularJS filter from a selection value

I have a table with a column of Status, and I want to filter the table base on their status and I have put on the selection element to do so. here is my code below for the selection

<select class="form-control" ng-model="OrdinanceStatus">
                                            <option value="">Select your option</option>
                                            <option value="1">Open</option>
                                            <option value="3">Amended</option>
                                            <option value="2">Due for amendment</option>
                                        </select>

and here is the table, Im thinking of ng-change but I dont know yet how to execute that

<div>
                        <table class="table table-bordered" id="headerTableRevenue">
                            <thead>
                                <tr>
                                    <td>LGU</td>
                                    <td>Title</td>
                                    <td>Status</td>
                                </tr>
                            </thead>
                            <tbody>
                                
                              <tr ng-repeat="a in OrdinanceReport | filter:{Status: OrdinanceStatus.Value}:true">
                                    <td>{{a.LGU}}</td>
                                    <td>{{a.OrdinanceTitle}}</td>
                                    <td>{{a.Status}}</td>
                                </tr> 
                            </tbody>
                        </table>
                    </div>

I tried putting this filter syntax inside the ng-repeat but its not working as expected of me.

filter:{Status: OrdinanceStatus.Value}:true

Upvotes: -1

Views: 21

Answers (1)

wei
wei

Reputation: 1005

Try to update your filter expression to below

filter:{ Status: OrdinanceStatus }:true

Refer Plunker: https://plnkr.co/edit/zLh6dHY6cvipiBbw

Upvotes: 0

Related Questions