2

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?

2 Answers 2

5

You could have something like below, which will place '' blank instead of nothing.

<tr ng-repeat="p in vm.projects | filter: {StatusID:(applicationStatus || '')}">
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.