Recently, I stumbled upon this interesting example fiddle showcasing the use of a comparator parameter to filter exact matches:
http://jsfiddle.net/api/post/library/pure/
The priority is supposed to be a number between 1-100, but due to inputting it as text and filtering it as a string, any data that includes a substring will also pass through the ng-repeat. For example, when typing '1', it displays not only '1' but also '11', '111', '132', etc., leading me to discover the ':true' comparator.
While some stackflow answers advised writing custom filter functions, using the true comparator seems to accomplish what I need with ease:
<input type="text" class="form-control" id="search.priority"
title='Priority number to filter by'
ng-model="search.priority" >
<tr ng-repeat="workflowItem in workflows | filter:search:true">
<td>{{workflowItem.priority}}</td>
This code successfully filters out exact matches only. However, the downside is that it won't display anything when the input field is empty, as there are no matches for an empty string.
Hence, my question arises: Is there a way to configure ng-repeat to show all items when the filter field is empty while still maintaining the exact match filter? Any suggestions or solutions would be greatly appreciated! Thank you!