计算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}} |