Reputation: 887
I have this select
<select ng-model="applicationStatus" ng-options="p.StatusID as p.Status for p in vm.projects | unique:'StatusID'">
<option value="">All</option>
</select>
And a list below that use the selected value as a filter:
<tr ng-repeat="p in vm.projects | filter: {StatusID:applicationStatus}">
This works, except when "All" is selected in the list (the predefined value) When "All" is selected I don't want the filter to be applied. What is the best way to achieve this?
Upvotes: 2
Views: 3948
Reputation: 136194
You could have something like below, which will place ''
blank instead of nothing.
<tr ng-repeat="p in vm.projects | filter: {StatusID:(applicationStatus || '')}">
Upvotes: 5
Reputation: 2450
You might need to create a custom filter to handle this scenario. Here's a good post about how to create one:
AngularJS filter by select with empty options
Upvotes: 0