相关疑难解决方法(0)

计算AngularJS ng-repeat中重复元素的总和

下面的脚本显示了使用的购物车ng-repeat.对于数组中的每个元素,它显示项目名称,其数量和小计(product.price * product.quantity).

计算重复元素总价的最简单方法是什么?

<table>

    <tr>
        <th>Product</th>
        <th>Quantity</th>
        <th>Price</th>
    </tr>

    <tr ng-repeat="product in cart.products">
        <td>{{product.name}}</td>
        <td>{{product.quantity}}</td>
        <td>{{product.price * product.quantity}} €</td>
    </tr>

    <tr>
        <td></td>
        <td>Total :</td>
        <td></td> <!-- Here is the total value of my cart -->
    </tr>

</table>
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-ng-repeat

107
推荐指数
5
解决办法
23万
查看次数

标签 统计

angularjs ×1

angularjs-ng-repeat ×1