Reputation: 1053
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!
Upvotes: 3
Views: 170
Reputation: 1053
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>
Upvotes: 1