My webpage utilizes a data object filled with information, but I need a way to filter this data within a specific section. I want to create an input field that filters through the data based on certain fields, rather than searching all the data in the object.
To demonstrate, I have created a quick example here
<div ng-init="friends = [{
random:{
tv: 'bbc'
},name:'John', phone:'555-1276'},
{random:{
tv:'bbc'},name:'Mary', phone:'800-BIG-MARY'},
{random:{
tv:'itv'},name:'Mike', phone:'555-4321'},
{random:{
tv:'itv'},name:'Adam', phone:'555-5678'},
{random:{
tv:'itv'},name:'Julie', phone:'555-8765'},
{random:{
tv:'itv'},name:'Juliette', phone:'555-5678'}]"></div>
Search: <input ng-model="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>
I have introduced a key called random, which includes a tv value like bbc. Currently, entering bbc in the search field displays all results, but my goal is to only search by name and/or phone.
Any assistance on achieving this would be highly appreciated.