Skip to content

Commit 0e27c4b

Browse files
author
Prashanth Batchu
committed
simple sum almost functional
1 parent 6b31b3c commit 0e27c4b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

billrive-client/app/js/controllers.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ billRive.controller('billController', function($scope, billService) {
3535
$scope.simpleCalculatedTotal=0;
3636
};
3737

38-
$scope.calculateSimpleSum=function(){
38+
$scope.simpleCalculateSum=function(){
3939

4040
$scope.simpleCalculatedTotal=0;
4141
for (i = 0; i < $scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost.length; i++) {
@@ -45,6 +45,15 @@ $scope.calculateSimpleSum=function(){
4545

4646

4747
};
48+
$scope.simpleFriendEnabled=function(){
49+
50+
for (i = 0; i < $scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost.length; i++) {
51+
if($scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost[i].enabled===false)
52+
$scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost[i].liableCost=0;
53+
}
54+
55+
$scope.simpleCalculateSum();
56+
};
4857

4958
});
5059

billrive-client/app/partials/addBill/simple.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<div class="row-fluid">
66

77
<div class="span3">
8-
<input type="checkbox" ng-model="user.enabled" />
8+
<input ng-change='simpleFriendEnabled()' type="checkbox" ng-model="user.enabled" />
99
<span class="done-{{!user.enabled}}"> {{user.name}}</span>
1010
</div>
1111
<div class="span3">
12-
<input ng-required='user.enabled' ng-disabled="!user.enabled" ng-change='calculateSimpleSum()' type="text" ng-model='user.liableCost' class="span6" placeholder="0.00" />
12+
<input ng-required='user.enabled' ng-disabled="!user.enabled" ng-change='simpleCalculateSum()' type="text" ng-model='user.liableCost' class="span6" placeholder="0.00" />
1313
</div>
1414
</div>
1515
</li>

0 commit comments

Comments
 (0)