Javascript 将以前所有项目的数据添加到ng repeat中的当前项目
我只想在第二列中将所有以前记录的金额添加到当前记录的金额中,如下所示。 [index-1]只添加上一条记录的金额,我想将所有的上一条记录的金额添加到当前记录的金额中。我该怎么办Javascript 将以前所有项目的数据添加到ng repeat中的当前项目,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我只想在第二列中将所有以前记录的金额添加到当前记录的金额中,如下所示。 [index-1]只添加上一条记录的金额,我想将所有的上一条记录的金额添加到当前记录的金额中。我该怎么办 <tr ng-repeat="record in records"> <td><span ng-if="record.status == 'unsettle' ">{{record.created_on}}</span></td>
<tr ng-repeat="record in records">
<td><span ng-if="record.status == 'unsettle' ">{{record.created_on}}</span></td>
<td><span ng-if="record.status == 'unsettle' ">{{record.amount+records[$index-1].amount}}</span></td>
</tr>
{{record.created{u on}}
{{record.amount+记录[$index-1].amount}
像这样试试看
<tr ng-repeat="record in records">
<td><span ng-if="record.status == 'unsettle' ">{{record.created_on}}</span></td>
<td><span ng-init="record.sum=record.amount+records[$index-1].sum" ng-if="record.status == 'unsettle' ">{{record.sum}}</span></td>
{{record.created{u on}}
{{record.sum}
也许这是一个完美的答案!但第一个指数仍然没有被加到总和中。我想不出原因,因为我是个新手。不过,非常感谢,先生。