使用 ng 表角度的列的总和

sum of columns using ng-table angular

本文关键字:ng 使用      更新时间:2023-09-26

我正在使用角度/ng表格以表格形式绘制数字数据。我无法弄清楚如何在表的末尾引入一行,该行显示每列所有值的总和。我可以在服务器端计算数据并将其呈现在 UI 中。但是有没有办法在ng-table/ng-grid中实现这一目标?任何帮助将不胜感激。

谢谢

你的意思是这样?

<table ng:init="stuff={items:[{description:'gadget', cost:99},{description:'thing', cost:101} ]}">
<tr>
    <th>Description</th>
    <th>Cost</th>
</tr>
<tr ng:repeat="item in stuff.items">
    <td>{{item.description}}</td>
    <td>{{item.cost}}</td>
</tr>
<tr>
    <td></td>
    <td>{{stuff.items.$sum('cost')}}</td>
</tr>