在angularjs中工作并希望根据从数据中检索的值保持运行总计.以下代码始终返回所有项目的完整总值.
<div ng-repeat="child in pItem.childItems | orderBy:'displayOrder'" ng-init="$parent.totalValue = $parent.totalValue + child.field[0].value">
Run Code Online (Sandbox Code Playgroud)
将其从父范围更改为子范围将清除每次重复的totalValue.因此,值始终等于该项的子值.
我正在寻找类似于以下内容的东西.其中Item1的值为2,Item2的值为3,Item3的值为4.