Protagonist
Protagonist

Reputation: 1669

How to filter unwanted rows in view from a table in AngularJs

I have a table and one of the columns is status. Values of status are 'Open', 'Closed', 'Verified' and 'Rejected'. How to write a filter in ng-repeat, so that rows whose status is 'Closed' should not be displayed.

Upvotes: 0

Views: 34

Answers (2)

Mathew Berg
Mathew Berg

Reputation: 28750

You should post some code of what you tried. Anyways...

ng-repeat="row in data | filter:{ Status: '!Closed' }"

Here's a jsFiddle show casing this:

http://jsfiddle.net/62za0fs7/

Upvotes: 3

Ashokreddy
Ashokreddy

Reputation: 352

<body ng-app="">
    <div ng-init="friends = [{name:'John', phone:'555-1276'},
                         {name:'Mary', phone:'800-BIG-MARY'},
                         {name:'Mike', phone:'555-4321'},
                         {name:'Adam', phone:'555-5678'},
                         {name:'Julie', phone:'555-8765'},
                         {name:'Juliette', phone:'555-5678'}]"></div>

    <label>Search: <input ng-model="searchText"></label>
    <table id="searchTextResults">
        <tr><th>Name</th><th>Phone</th></tr>
        <tr ng-repeat="friend in friends | filter:searchText">
            <td>{{friend.name}}</td>
            <td>{{friend.phone}}</td>
        </tr>
    </table>
</body>

Upvotes: -2

Related Questions