最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - sum of columns using ng-table angular - Stack Overflow

programmeradmin0浏览0评论

I am using angular/ng-table to plot numerical data in tabular form. I am not able to figure out how to bring in a row at the end of my table which shows sum of all the values of each column. I can pute the data on the server side and present it in the UI. But is there a way to achieve this in ng-table/ng-grid? Any help will be appreciated.

thanks

I am using angular/ng-table to plot numerical data in tabular form. I am not able to figure out how to bring in a row at the end of my table which shows sum of all the values of each column. I can pute the data on the server side and present it in the UI. But is there a way to achieve this in ng-table/ng-grid? Any help will be appreciated.

thanks

Share Improve this question asked Oct 3, 2013 at 16:55 poshakposhak 1051 gold badge3 silver badges11 bronze badges 2
  • What of summing in the controller using the data retrieved from the server? – kubuntu Commented Oct 3, 2013 at 17:02
  • you can access your data array. You just need to do it in JS in the controller and show it in the template. – maxisam Commented Oct 3, 2013 at 19:22
Add a ment  | 

1 Answer 1

Reset to default 4

You mean something like this?

<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>

发布评论

评论列表(0)

  1. 暂无评论