Reputation: 818
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?
Upvotes: 0
Views: 59
Reputation: 861
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.
Upvotes: 1
Reputation: 747
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!
Upvotes: 0