我想總結使用JSON數組動態添加的產品數量。如何在AngularJS ng-repeat中求和Json數組值
<tr ng-repeat="(key,val) in form.products">
<td>{{ProductName(key)}}</td>
<td >
<input type="text" name="products" ng-model="form.products[key]" class="form-control">
</td>
</tr>
我怎樣才能得到上述例子中的產品總和?
得到計數控制器,並使其在$範圍可用於模板在NG-repeate – gimbel0893
使用這個我試過$ scope.calculateSum =函數(){ VAR 總和= 0; 爲(VAR I = 0; I <$ scope.products.length;我++){ \t \t \t \t \t總和+ = parseFloat($ scope.products [I]); \t \t } return sum; }但無法正常工作,我在模板中調用了。我是新角JS的 – Robin