ng-根据条件显示表格记录 [英] ng-Show records of table on condition
问题描述
我试图显示行及其列的值之和.它具有三种保持状态的状态.
1)自动2)直播3)autolive(不存在于json中,需要自动和实时组合成行)
结论:
在siteData.jobType == toggleValue上,如果(toggleValue == auto),则显示自动"记录
在siteData.jobType == toggleValue(toggleValue == live)上,它显示实时"记录
但是在siteData.jobType == toggleValue(toggleValue == autolive)上,它没有显示任何记录,因为json中不存在coz autolive
如何实现以显示自动和实时记录的组合?
//自定义切换按钮
当我切换为自动直播时,我希望所有这些人
尝试以下解决方法: ng-show ="toggleValue.indexOf(siteData.jobType)> -1"
I am trying to show rows and their sum of value of columns. It has three states on which condition held.
1) auto 2) live 3) autolive (not present in json, need auto and live combine in rows)
Conclusion:
On siteData.jobType==toggleValue if (toggleValue==auto ), it shows records of "auto"
On siteData.jobType==toggleValue (toggleValue==live ), it shows records of "live"
But on siteData.jobType==toggleValue (toggleValue==autolive ), it shows no record , coz autolive is not present in json
How can I achieve it to show combine records of auto and live?
// custom toggle button 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 format
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
}
]
}
I want all of them when i toggle autolive
try this workaround: ng-show="toggleValue.indexOf(siteData.jobType) > -1"
这篇关于ng-根据条件显示表格记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!