0

For default must show items that have prop "state: 'notarchived'" and "state: 'archived'" must be hided When I have a Check I need hide elemets with "state: 'notarchived'" and show elements with "state: 'archived'"

There my HTML

<th><input ng-model="archived.state"  type="checkbox"
      ng-true-value="'archived'" ng-false-value="undefined">Show archived</th>


<tr  ng-repeat="paymentinfo in paymentList | filter:keyword | filter:money | filter:getdate | filter:{state: 'notarchived'}: archived.state ? true : true">
          <td>{{paymentinfo.date}}</td>
          <td ng-click="singlepage(paymentinfo.id)" ><a>{{paymentinfo.name}}</a> </td></tr>

JS

 $scope.datas = [
            {date:'06-12-2016', name : 'Pinao Class', state: 'archived', remark : 'remarled', amount : 101, id : 21},
            {date:'15-04-2016', name : 'drivers Class', state: 'notarchived', remark : 'remarled', amount : 102, id : 22},
            {date:'24-03-2016', name : 'Airplane Class', state: 'archived', remark : 'remarled', amount : 103, id : 23}

    ];

$scope.paymentList = $scope.datas;

Now displayes all elements How to change filter that it work right way?

2 Answers 2

1

Try this one:

Set the initial value for the checkbox:

<input ng-model="archived.state"  type="checkbox"
      ng-true-value="'archived'" ng-false-value="'notarchived'" 
      ng-init="archived.state='notarchived'">Show archived</th>

and change the filter:

<tr ng-repeat="paymentinfo in paymentList | filter:keyword | filter:money | filter:getdate | filter:{state: archived.state}:true">

I tried and it works.

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

Comments

0

This is untested for I don't have a proper environment setup

<th><input ng-model="archived.state" type="checkbox" ng-true-value="'archived'" ng-false-value="'notarchived'">Show archived</th>

filter:{state: archived.state ? 'archived' : 'notarchived'}

Please test and let me know. Thanks!

1 Comment

For default. show notarchived, after pressing check all items displaying, after uncheck. nothing happens

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.