以下是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>
我需要在对象存档时显示一个div
,并在对象有另一个参数时显示另一个
我试着这样做:
<div ng-switch on="paymentinfo.archived">
<div ng-switch-when="archived">11</div>
<div ng-switch-default>222</div>
</div>
但是我的代码出了点问题。
我的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;
答案 0 :(得分:2)
您需要更改切换变量:
<div ng-switch on="paymentinfo.state">
<div ng-switch-when="archived">11</div>
<div ng-switch-default>222</div>
</div>
因为您的paymentInfo对象没有“archieved”键的元素。 ng-switch将值paymentinfo.state与ng-switch-when语句中的值进行比较。
答案 1 :(得分:0)
您需要使用paymentinfo.state
代替paymentinfo.archived
以下是ng-switch
:JS Fiddle ng-switch