我想通過ng-hide和ng-show機制顯示行和它們的的值的總和列。它有三個州在哪個條件下舉行。計算ng-hide和ng-show表的記錄值的計數
1)自動
2)住
3)autolive(不是JSON目前,需要汽車和生活結合起來,行)
結論:
在siteData。 jobType == toggleValue if(toggleValue == auto),它顯示「auto」的記錄
on siteData.jobType == togg leValue(toggleValue ==直播),這表明 「活」 的記錄
但在siteData.jobType == toggleValue(toggleValue == autolive),它顯示了合併結果現在
,問題是數不在切換值更改時執行,當頁面加載時,我希望它在切換時更改時,它保持相同的組合結果。
在類型汽車它應該是:4 在類型現場它應該是:2
在參考案例:ng-Show records of table on condition
//自定義切換按鈕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="toggleValue.indexOf(siteData.jobType) > -1" >
<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
}
]
}
因此,您希望根據切換值顯示當前顯示的記錄數。是對的嗎? – tanmay
是@tanmay,正是我想 – Creator
添加了我的答案。我希望這次你會用正確的方式去:) – tanmay