anjularjs中多个变量同时监听

<table class="table table-striped table-hover" style="font-size: 13px">
    <thead>
    <tr>
        <th style="width:15%">贷款明细</th>
        <th style="width:15%">贷款类型</th>
        <th style="width:15%">贷款金额(元)</th>
        <th style="width:15%">贷款余额(元)</th>
        <th style="width:15%">贷款期限</th>
        <th style="width:15%">月供(元)</th>
        <th style="width:10%">操作</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="item in unclearedLoanSummary">
        <td>
            <input type="text"  class="form-control" id ='loanDetail' ng-maxlength="32" ng-model="item.loanDetail" required>
        </td>
        <td>
            <input type="text"  class="form-control" id ='loanType' ng-maxlength="32" ng-model="item.loanType" required>
        </td>
        <td>
            <input type="number" step="0.1" class="form-control" id ='loanAmount' ng-maxlength="12" ng-model="item.loanAmount" required>
        </td>
        <td>
            <input type="number" step="0.1" class="form-control" id ='loanBalance' ng-maxlength="12" ng-model="item.loanBalance" required>
        </td>
        <td>
            <input type="number"  class="form-control" id ='loanPeriod' ng-maxlength="5" ng-model="item.loanPeriod" required>
        </td>
        <td>
            <input type="number" step="0.1" class="form-control" id ='monthRent' ng-maxlength="12" ng-model="item.monthRent" required>
        </td>
        <td>
            <button class="btn btn-danger btn-sm" type="button" ng-click="deleteUnclearedLoanSummaryRow($index)"><i class="fa fa-times m-r-sm"></i>删除</button>
        </td>
    </tr>
    </tbody>
</table>

 

 

 

 

 

service中监听:
var watchMonthRent = $scope.$watch('{a:unclearedLoanSummary,b:externalGuaranteeSummary,c:activatedCreditcardSummary}',function(newVal,oldVal){
    var sum=0;
    if(newVal!=oldVal){
        var arr=newVal.a.concat(newVal.b).concat(newVal.c);
        for(var k=0;k<arr.length;k++){
            var item=arr[k];
            sum+=item.monthRent;
        }
        $scope.customCreditSummary.monthRentTotalAmount=sum;
    }
},true);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值