I am implementing a search input box that should search based off of a certain property of the objects that are getting iterated over and I would like them to be selected using a radio button.
For example here is my code:
<span style="margin-bottom: 10px; display: inline-block;">Search: <input ng-model="searchText.CustomerName" /> </span> <table id="Table1" class="alertTable"> <thead> <tr> <th class="xsmCol"><img src="/App_Themes/SkyKick/images/misc/clear.gif" class="iFlag" /></th> <th>Subject</th> <th>Customer</th> <th>Type</th> <th>Date</th> <th class="smCol">Actions</th> </tr> </thead> <tbody id="tbAlerts"> <tr ng-repeat-start="alert in alerts | filter:searchText" > <!-- | filter:searchText --> <td><img src="/App_Themes/SkyKick/images/misc/clear.gif" data-tooltip="{{ alert.tooltip }}" class="{{ 'iAlert' + alert.AlertType }}"/></td> <td><a href="Show Alert Details" ng-click="showAlertDetails($event)">{{ alert.Summary }}</a></td> <td>{{ alert.CustomerName }}</td> <td>{{ alert.CreatedDate }}</td> <td>{{ alert.Category }}</td> <td> <!-- Tricky little widget logic --> </td> </tr> <tr ng-repeat-end class="alertDetail"> <td></td> <td colspan="5" ng-bind-html="alert.Details"></td> </tr> </tbody> </table>
As you can see, I am currently filtering based off of the CustomerName field in my array. However, I want to change the logic so that I can select between CustomerName, Subject, Type, and Date using a radio button. So if the user clicks the Date radio button, then the searchText will filter only based off the Date attribute. What is the best way to get this functionality?