加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 09:11:02 所属栏目:安全 来源:网络整理
导读:下面的脚本显示使用ng-repeat的商店购物车。对于数组中的每个元素,它将显示项目名称,其数量和小计(product.price * product.quantity)。 什么是最简单的计算重复元素的总价格的方法? table tr thProduct/th thQuantity/th thPrice/th /tr tr ng-repeat="p
下面的脚本显示使用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}}                         

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读