Reputation: 818
Here's a list of objects that's shown by ng-repeat
:
<tr ng-repeat="paymentinfo in paymentList | filter:keyword | filter:money | filter:getdate | filter:{state: archived.state}">
<td>{{paymentinfo.date}}</td>
<td ng-click="singlepage(paymentinfo.id)" ><a>{{paymentinfo.name}}</a> </td>
<td>
<div class="grey-flag remark-payment">
<div class="hover-remark">{{paymentinfo.remark}}</div>
</div>
</td>
<td>$ {{paymentinfo.amount}}</td>
<td id="outmouse">
<ul style="list-style: none;" class="gt-reset">
<li class="dropdown changecoursename">
<a class="dropdown-toggle" data-toggle="dropdown">
<span class="tableOperation norlmalstate">Open Course</span>
<span class="tableOperation openedstate">more options</span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a class="tableOperation" ng-click="paymentRemarks()">Remarks</a></li>
<li><a class="tableOperation" ng-click="paymentReturn(paymentinfo)">Return</a></li>
<li >
<a class="tableOperation" ng-click="paymentDelete(paymentinfo)">Delete</a>
<div ng-switch on="paymentinfo.archived">
<div ng-switch-when="archived">11</div>
<div ng-switch-default>222</div>
</div>
</li>
</ul>
</li>
</ul>
</td>
</tr>
There I need to show one div
when object has a param archived, and show another when object has another param
I tried to do this:
<div ng-switch on="paymentinfo.archived">
<div ng-switch-when="archived">11</div>
<div ng-switch-default>222</div>
</div>
But something is wrong in my code.
My 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},
{date:'28-02-2016', name : 'burger Class', state: 'notarchived', remark : 'remarled', amount : 104, id : 24},
{date:'28-02-2016', name : 'burger Class1', state: 'notarchived', remark : 'remarled', amount : 104, id : 241},
{date:'28-02-2016', name : 'burger Class2', state: 'notarchived', remark : 'remarled', amount : 104, id : 2432},
{date:'28-02-2016', name : 'burger Class3', state: 'notarchived', remark : 'remarled', amount : 104, id : 2342},
{date:'28-02-2016', name : 'burger Class4', state: 'archived', remark : 'remarled', amount : 104, id : 2443},
{date:'28-02-2016', name : 'burger Class5', state: 'archived', remark : 'remarled', amount : 104, id : 2243},
{date:'28-02-2016', name : 'burger Class6', state: 'archived', remark : 'remarled', amount : 104, id : 2242}
];
$scope.paymentList = $scope.datas;
Upvotes: 0
Views: 61
Reputation: 1859
You need to use paymentinfo.state
instead of paymentinfo.archived
And here is an example for ng-switch
: JS Fiddle ng-switch
Upvotes: 0
Reputation: 861
You need to change your switch variable:
<div ng-switch on="paymentinfo.state">
<div ng-switch-when="archived">11</div>
<div ng-switch-default>222</div>
</div>
because your paymentInfo object does not have an element with the key "archieved". ng-switch compares the value paymentinfo.state with the values in ng-switch-when statement.
Upvotes: 2