3

I am applying filter based on whether a record is active or not. There are basically three things 1)show all record 2)show active ones 3)show only those which are inactive

I can easily apply filtering for active or inactive using following code

<div  ng-repeat="payhead in payHeadsList | filter:search">


<div style="float:left;width:65%" class="">
                <span style="float:left;" class="BodyTxt3 ML1">Show</span> 
                <select
                class="W2_Normal BodyTxt3 V4 ML1" style='float:left' id="selectPayHead"
                ng-model="search.ph_active"
                ng-options="a.value as a.name for a in payHeadOption"></select>
                </span>
 </div>


$scope.payHeadOption=[{name:"All Payhead",value:3},{name:"Active Payhead",value:1},{name:"Inactive Payhead",value:0}];

so on selecting Active Payhead/Inactive Payhead ,it filters out record with search.ph_active=0 or 1. But I need to show all records on selection of All Payhead. What is the way here?

3
  • would {name:"All Payhead",value:null} do the trick? Commented Aug 20, 2014 at 8:50
  • @maurycy tried it,but sadly it too filter outs all records. Commented Aug 20, 2014 at 8:52
  • what about empty value? value:'' Commented Aug 20, 2014 at 8:53

1 Answer 1

2

If you use an empty string it's like you don't specify filter criteria at all so all elements are shown, my first thought was to use null but it looks like null would be an actual value to compare while empty string match all elements

{name:"All Payhead",value:''}
Sign up to request clarification or add additional context in comments.

2 Comments

so do you mean if we put null as value then it will check for those elements which have "null" as specified property???
Yes, that's what I meant

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.