我想将检查对象推送到新阵列&我的角度/ HTML代码也是总价格的总和/数量:
<div class="panel panel-default" ng-repeat="daysheet in daysheets">
<div class="panel-heading">
<h1 class="panel-title">{{daysheet.charge_client_name}}</h1>
</div>
<div class="panel-body">
<form class="form_{{daysheet.id}}">
<table class="table">
<thead>
<tr>
<th>Qty</th>
<th>Rate</th>
<th>Total</th>
<th>Invoice</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="jobd in daysheet.job_details">
<td style="width: 70px">
<input type="text" name="qty[]" value="{{jobd.product_quantity}}" class="form-control ">
</td>
<td style="width: 80px">
<input type="text" value="{{jobd.job_product_rate}}" name="rate[]" class="form-control " disabled>
</td>
<td>
<input type="text" value="{{jobd.job_product_total_rate}}" name="total[]" ng-model="total" class="form-control total_count">
</td>
<td> //checkbox when user checked show this object amount and push value in new array
<input type="checkbox" name="send_in[]" class="invoice_s_{{daysheet.id}}" ng-model="selectedjob">
</td>
</tr>
<tr>
<td colspan="13">
<p class="pull-right "> Selected joblines Total <u>// select checkbox amount(job_product_total_rate) / sum of all selected checkbox total amount(job_product_total_rate) goes here</u>
</p>
<p class="pull-right "> Total Amount <u class="tot_amt">//total amount goes here</u>
</p>
</td>
</tr>
</tbody>
</table>
</form>
</div>
和API响应是:
[
{
"id":"2",
"charge_client_name":"Ridgeway Bank",
"job_details":[
{
"job_id":"4",
"product_quantity":"55",
"job_product_rate":"120",
"job_product_total_rate":"6600",
"distance":"200"
},
{
"job_id":"2",
"product_quantity":"55",
"job_product_rate":"120",
"job_product_total_rate":"6600",
"distance":"12"
}
]
},
{
"id":"1",
"charge_client_name":"Woolworths Market",
"job_details":[
{
"job_id":"1",
"product_quantity":"1200",
"job_product_rate":"1200",
"job_product_total_rate":"1440000",
"distance":"100"
}
]
}]
其中我想显示所有对象的所有金额/总金额,例如{job_product_total_rate}的所有总和,以及当我们点击/选中新数组中的复选框推送对象值时。 提前谢谢
答案 0 :(得分:1)
以下是您的示例: https://jsfiddle.net/e9ps7oa7/
您可以使用checklist-model创建带复选框的列表。
$scope.getTotalAmount
函数用于计算数组中的属性总和
你可以在daysheet.selected
数组