11billRive . controller ( 'billController' , function ( $scope , billService ) {
2-
3- //$scope.bills= billService.getBills();
4-
52 $scope . friends = billService . getFriends ( ) ;
63 $scope . groups = billService . getGroups ( ) ;
74 $scope . payers = billService . getPayers ( ) ;
@@ -12,10 +9,7 @@ billRive.controller('billController', function($scope, billService) {
129 $scope . addBill = function ( ) {
1310
1411 } ;
15- //console.log( $scope.friends);
16-
1712 $scope . setBillGroup = function ( ) {
18- // console.log(id);
1913 var $groupId = $scope . bill . groupId ;
2014
2115 var $groupMembers ;
@@ -27,68 +21,29 @@ billRive.controller('billController', function($scope, billService) {
2721 }
2822 }
2923 var $groupUserAndLiableCost = [ ] ;
30- console . log ( $scope . friends [ 0 ] . id ) ;
3124 var $friendNamefromId = null ;
3225 for ( i = 0 ; i < $groupMembers . length ; i ++ ) {
3326
3427 for ( var j = 0 ; j < $scope . friends . length ; j ++ ) {
35-
36- //
3728 if ( $scope . friends [ j ] . id == $groupMembers [ i ] )
38- {
3929 $friendNamefromId = $scope . friends [ j ] . name ;
40- }
41- //
4230 }
4331 $groupUserAndLiableCost . push ( { userId : $groupMembers [ i ] , liableCost : null , name : $friendNamefromId } ) ;
4432 }
45-
46- //console.log($groupUserAndLiableCost);
47- // for(var i=0;i<)
48- // var $userAndLiableCost=
49- $scope . bill . billFinances . billItemEntry = $groupUserAndLiableCost ;
33+ $scope . bill . billFinances . billSimpleTotals . userIdAndLiableCost = $groupUserAndLiableCost ;
5034 $groupUserAndLiableCost = [ ] ;
51- //$scope.bill.billFinances.billItemEntry.push($groupUserAndLiableCost);
52- //console.log($userAndLiableCost);
35+
5336 } ;
5437
38+ $scope . calculateSimpleSum = function ( ) {
39+
40+ $scope . simpleCalculatedTotal = 0 ;
41+ for ( i = 0 ; i < $scope . bill . billFinances . billSimpleTotals . userIdAndLiableCost . length ; i ++ ) {
42+ $scope . simpleCalculatedTotal += parseInt ( $scope . bill . billFinances . billSimpleTotals . userIdAndLiableCost [ i ] . liableCost ) ;
43+ }
44+
45+
46+ } ;
5547
56- // billService.getBills(function(data) {
57- // $scope.bills = data;
58- // $scope.username ="Prashanth";
59- //
60- //
61- //$scope.friends= [
62- //{name:'John Doe'},
63- //{name:'Kristen Stewart'},
64- //{name:'Trevor Pott'},
65- //{name:'Hilda Hess'},
66- //{name:'Gavin Mays'}
67- //];
68- //
69- //
70- //$scope.groups= [
71- //{name:'SLC Roommates'},
72- //{name:'Denver Old Buddies'},
73- //{name:'Ski Club'},
74- //{name:'Family'},
75- //{name:'India'}
76- //];
77- //
78- // function addBill(){
79- //
80- //// $scope.bills.put();
81- // };
82- //
83- // function deleteBill(){
84- //
85- //
86- // };
87- //
88- // function editBill(){
89- //
90- //
91- // };
92- // });
9348} ) ;
9449
0 commit comments