我试图显示行及其列的总和。它具有三个保持状态的状态。
1)自动
2)现场
3)autolive(不存在于json中,需要自动和实时组合成行)
结论:
在siteData.jobType == toggleValue上,如果(toggleValue == auto),则显示“自动”记录
在siteData.jobType == toggleValue(toggleValue == live)上,它显示“实时”记录
但是在siteData.jobType == toggleValue(toggleValue == autolive)上,它没有显示记录,因为json中不存在coz autolive
如何显示自动和实时记录?
//自定义切换按钮https://github.com/tannerlinsley/nz-toggle
<nz-toggle
tri-toggle
on-toggle="myFunction()"
ng-model="toggleValue"
val-true="'auto'"
val-false="'live'"
val-null="'autolive'">
</nz-toggle>
<table class="table table-condensed" border ="1" >
<thead>
<tr>
<th>PiteId</th>
<th>PiteId</th>
<th>Type</th>
<th>Date</th>
<th >Success</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="siteData in siteObject" ng-show="siteData.jobType==toggleValue" >
<td>{{siteData.sid}}</td>
<td>{{siteData.PiteId}}</td>
<td>{{siteData.Type}}</td>
<td>{{siteData.Date}}</td>
<td ng-init="siteObject.total.siteData.countSuccess = siteObject.total.siteData.countSuccess + siteData.countSuccess">{{siteData.countSuccess}}</td>
</tr>
</table>
json格式
siteObject =
{
"data": [
{
"sid": 1,
"PiteId": "1~10-4-2017~15:13:40",
"Type": "live",
"Date": "2017-04-14T18:30:00.000Z",
"countSuccess": 1
},
{
"sid": 1,
"PiteId": "1~10-4-2017~15:13:40",
"Type": "auto",
"Date": "2017-04-14T18:30:00.000Z",
"countSuccess": 1
}
]
}
当我切换为自动直播时,我想要所有这些
最佳答案
尝试以下解决方法:ng-show="toggleValue.indexOf(siteData.jobType) > -1"