I'm trying to disable the filter when I select the "all" option for my select ng-model.
Here's the code:
Search: <input ng-model="searchText">
Search By:
<select ng-model="queryBy">
<option value="$">all</option>
<option value="1">category 1</option>
<option value="2">category 2</option>
<option value="3">category 3</option>
</select>
<ul>
<li ng-repeat="message in messages | filter:searchText | filter: {category: queryBy}"></li>
</ul>
When I select the first option ("$"), I want the filter to be disabled. Is there a way to do this? Thanks!
I just figured it out myself. I just had to change the "$" to "", an empty string. Since an empty string doesn't specify a filter criteria, a filter isn't applied. So the revised code would be:
<select ng-model="queryBy">
<option value="">all</option>
<option value="1">category 1</option>
<option value="2">category 2</option>
<option value="3">category 3</option>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With