Angular Filtering example

Shows how to apply filter to repeater array

by dandoyon

HTML

<script src="http://code.angularjs.org/angular-0.9.18.min.js" ng:autobind></script>
<div xmlns:ng="http://angularjs.org" 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'}]"></div>

Search: <input name="searchText"/>
<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>
<hr>
Any: <input name="search.$"/> <br>
Name only <input name="search.name"/><br>
Phone only <input name="search.phone"/><br>
<table id="searchObjResults">
    <tr><th>Name</th><th>Phone</th></tr>
    <tr ng:repeat="friend in friends.$filter(search)">
        <td>{{friend.name}}</td>
        <td>{{friend.phone}}</td>
    </tr>
</table>