0

I have this ng-repeat condition:

<tr ng-repeat="(k, v) in loanapps | filter:{LoanStatus:SelectedStatus}:true track by $index"> <td> {{v.Id}} </td> <td> {{v.Name}} </td> </tr> 

Filtering works fine when I have SelectedStatus value. Now I also want to reset the filter and display all the results.

I have this button click function:

$scope.ResetStatusFilter = function() { $scope.SelectedStatus = null; } 

I also tried:

$scope.ResetStatusFilter = function() { $scope.SelectedStatus = ''; } 

But what this is doing is clearing out all the results.

Is there anyway how can I display all the results and exclude the filter once the button is clicked?

The select list is this one:

<select ng-model="SelectedStatus"> <option value="Under Review">Under Review</option> <option value="Waiting for Meeting">Waiting for Meeting</option> <option value="Processing">Processing</option> </select> 
3
  • Use custom filter - docs.angularjs.org/guide/filter Commented Dec 5, 2016 at 15:49
  • thx @bhantol can you pls give me example how should I apply custom filter in my case, thanks Commented Dec 5, 2016 at 15:52
  • what is the default value of selectedstatus when the list first loads, and have you tried setting it back to that value? Commented Dec 5, 2016 at 15:56

3 Answers 3

1

try changing filter:{LoanStatus:SelectedStatus}:true to filter:SelectedStatus.

Sign up to request clarification or add additional context in comments.

2 Comments

who will the table know for which field is that applied? Thx for help
Might want to refer to the documentation, but i believe the filter will search the whole object by default for your string value. Double check @ docs.angularjs.org/api/ng/filter/filter
0

Try this short circuiting technique.

<tr ng-repeat="(k, v) in loanapps | filter: (LoanStatus.SelectedStatus && {LoanStatus:SelectedStatus}:true) track by $index"> 

Comments

0

instead of using filter:{LoanStatus:SelectedStatus}:true to filter:SelectedStatus.

you can clear your filter by using

$scope.SelectedStatus ={} 

it will clear the filter

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.