Skip to content

Commit 827f298

Browse files
author
Prashanth Batchu
committed
converted service to a factory. Moved all JSON manual setting to factory. More structure.
1 parent 4b58ff3 commit 827f298

File tree

4 files changed

+268
-57
lines changed

4 files changed

+268
-57
lines changed

billrive-client/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</ul>-->
1616

1717
<!--</div>-->
18-
18+
1919
<div class="navbar navbar-fixed-top">
2020
<div class="navbar-inner">
2121
<div class="container">
Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
billRive.controller('billController', function($scope, billService) {
2-
billService.getBills(function(data) {
3-
$scope.bills = data;
4-
$scope.username ="Prashanth";
5-
$scope.payers= [
6-
{name:'John Doe'},
7-
{name:'Kristen Stewart'},
8-
{name:'Trevor Pott'},
9-
{name:'Hilda Hess'},
10-
{name:'Gavin Mays'}
11-
];
12-
13-
14-
$scope.friends= [
15-
{name:'John Doe'},
16-
{name:'Kristen Stewart'},
17-
{name:'Trevor Pott'},
18-
{name:'Hilda Hess'},
19-
{name:'Gavin Mays'}
20-
];
21-
22-
23-
$scope.groups= [
24-
{name:'SLC Roommates'},
25-
{name:'Denver Old Buddies'},
26-
{name:'Ski Club'},
27-
{name:'Family'},
28-
{name:'India'}
29-
];
30-
31-
function addBill(){
32-
33-
// $scope.bills.put();
34-
};
35-
36-
function deleteBill(){
37-
38-
39-
};
40-
41-
function editBill(){
42-
43-
44-
};
45-
});
2+
3+
$scope.bills= billService.getBills();
4+
5+
$scope.friends=billService.getFriends();
6+
$scope.groups=billService.getGroups();
7+
$scope.payers=billService.getPayers();
8+
// billService.getBills(function(data) {
9+
// $scope.bills = data;
10+
// $scope.username ="Prashanth";
11+
//
12+
//
13+
//$scope.friends= [
14+
//{name:'John Doe'},
15+
//{name:'Kristen Stewart'},
16+
//{name:'Trevor Pott'},
17+
//{name:'Hilda Hess'},
18+
//{name:'Gavin Mays'}
19+
//];
20+
//
21+
//
22+
//$scope.groups= [
23+
//{name:'SLC Roommates'},
24+
//{name:'Denver Old Buddies'},
25+
//{name:'Ski Club'},
26+
//{name:'Family'},
27+
//{name:'India'}
28+
//];
29+
//
30+
// function addBill(){
31+
//
32+
//// $scope.bills.put();
33+
// };
34+
//
35+
// function deleteBill(){
36+
//
37+
//
38+
// };
39+
//
40+
// function editBill(){
41+
//
42+
//
43+
// };
44+
// });
4645
});

billrive-client/app/js/services.js

Lines changed: 212 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,214 @@
1-
'use strict';
2-
3-
/* Services */
4-
billRive.factory('billService',function($http){
5-
6-
return {
7-
8-
getBills: function(callback){
9-
$http.get('http://localhost:8080/billrive-service/rest/2/bills/').success(callback);
1+
//'use strict';
2+
//
3+
///* Services */
4+
//billRive.factory('billService',function($http){
5+
//
6+
// return {
7+
//
8+
// getBills: function(callback){
9+
// $http.get('http://localhost:8080/billrive-service/rest/2/bills/').success(callback);
10+
// }
11+
// };
12+
//});
13+
14+
billRive.factory('billService',function(){
15+
var factory = {};
16+
// var getBills=function(){
17+
// var bills= [
18+
// {title:"Walmart",date:"05/03/2013",total:"55.84"},
19+
// {title:"Costco",date:"05/01/2013",total:"35.00"},
20+
// {title:"Sams",date:"04/21/2013",total:"101.85"},
21+
// {title:"Farmers Market",date:"04/03/2013",total:"43.5"}
22+
// ];
23+
24+
25+
var bills = [{
26+
"data": [
27+
{
28+
"id": 1,
29+
"title": "Walmart",
30+
"date": {
31+
"year": 2013,
32+
"dayOfMonth": 3,
33+
"dayOfWeek": 7,
34+
"era": 1,
35+
"dayOfYear": 34,
36+
"weekOfWeekyear": 5,
37+
"minuteOfDay": 61,
38+
"minuteOfHour": 1,
39+
"monthOfYear": 2,
40+
"millisOfSecond": 0,
41+
"yearOfCentury": 13,
42+
"secondOfDay": 3660,
43+
"centuryOfEra": 20,
44+
"millisOfDay": 3660000,
45+
"secondOfMinute": 0,
46+
"weekyear": 2013,
47+
"hourOfDay": 1,
48+
"yearOfEra": 2013,
49+
"zone": {
50+
"uncachedZone": {
51+
"fixed": false,
52+
"cachable": true,
53+
"id": "America/Denver"
54+
},
55+
"fixed": false,
56+
"id": "America/Denver"
57+
},
58+
"millis": 1359878460000,
59+
"chronology": {
60+
"zone": {
61+
"uncachedZone": {
62+
"fixed": false,
63+
"cachable": true,
64+
"id": "America/Denver"
65+
},
66+
"fixed": false,
67+
"id": "America/Denver"
68+
}
69+
},
70+
"beforeNow": true,
71+
"afterNow": false,
72+
"equalNow": false
73+
},
74+
"billPayerId": 2,
75+
"notes": "Sample Notes",
76+
"billFinances": {
77+
"billPayerId": 1,
78+
"billItemEntry": [
79+
{
80+
"itemDescriptionId": 1,
81+
"itemDescription": "Canola Oil",
82+
"userIdAndLiableCost": [
83+
{
84+
"userId": 2,
85+
"liableCost": 10
86+
},
87+
{
88+
"userId": 3,
89+
"liableCost": 20
90+
}
91+
]
92+
},
93+
{
94+
"itemDescriptionId": 2,
95+
"itemDescription": "Taco Bell",
96+
"userIdAndLiableCost": [
97+
{
98+
"userId": 4,
99+
"liableCost": 50
100+
},
101+
{
102+
"userId": 5,
103+
"liableCost": 40
104+
}
105+
]
106+
}
107+
],
108+
"billTotal": 30
109+
},
110+
"groupId": 2
111+
},
112+
{
113+
"id": 2,
114+
"title": "Costco",
115+
"date": {
116+
"year": 2014,
117+
"dayOfMonth": 3,
118+
"dayOfWeek": 1,
119+
"era": 1,
120+
"dayOfYear": 34,
121+
"weekOfWeekyear": 6,
122+
"minuteOfDay": 61,
123+
"minuteOfHour": 1,
124+
"monthOfYear": 2,
125+
"millisOfSecond": 0,
126+
"yearOfCentury": 14,
127+
"secondOfDay": 3660,
128+
"centuryOfEra": 20,
129+
"millisOfDay": 3660000,
130+
"secondOfMinute": 0,
131+
"weekyear": 2014,
132+
"hourOfDay": 1,
133+
"yearOfEra": 2014,
134+
"zone": {
135+
"uncachedZone": {
136+
"fixed": false,
137+
"cachable": true,
138+
"id": "America/Denver"
139+
},
140+
"fixed": false,
141+
"id": "America/Denver"
142+
},
143+
"millis": 1391414460000,
144+
"chronology": {
145+
"zone": {
146+
"uncachedZone": {
147+
"fixed": false,
148+
"cachable": true,
149+
"id": "America/Denver"
150+
},
151+
"fixed": false,
152+
"id": "America/Denver"
153+
}
154+
},
155+
"beforeNow": false,
156+
"afterNow": true,
157+
"equalNow": false
158+
},
159+
"billPayerId": 2,
160+
"notes": "Second sample Notes",
161+
"billFinances": {
162+
"billPayerId": 2,
163+
"billItemEntry": [],
164+
"billTotal": 90
165+
},
166+
"groupId": 2
10167
}
11-
};
168+
]
169+
}];
170+
171+
var payers= [
172+
{name:'John Doe'},
173+
{name:'Kristen Stewart'},
174+
{name:'Trevor Pott'},
175+
{name:'Hilda Hess'},
176+
{name:'Gavin Mays'}
177+
];
178+
179+
var friends= [
180+
{name:'John Doe'},
181+
{name:'Kristen Stewart'},
182+
{name:'Trevor Pott'},
183+
{name:'Hilda Hess'},
184+
{name:'Gavin Mays'}
185+
];
186+
187+
188+
var groups= [
189+
{name:'SLC Roommates'},
190+
{name:'Denver Old Buddies'},
191+
{name:'Ski Club'},
192+
{name:'Family'},
193+
{name:'India'}
194+
];
195+
196+
factory.getBills=function(){
197+
return bills;
198+
};
199+
200+
factory.getPayers=function(){
201+
return payers;
202+
};
203+
204+
factory.getFriends=function(){
205+
return friends;
206+
};
207+
208+
factory.getGroups=function(){
209+
return groups;
210+
};
211+
212+
213+
return factory;
12214
});

billrive-client/app/partials/listBills.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020
</tr>
2121
</thead>
2222
<tbody>
23-
<tr ng-repeat="bill in bills.data | filter:query">
23+
<!-- <tr ng-repeat="bill in bills | filter:query">
24+
<td>{{ bill.date}}</td>
25+
<td>{{ bill.title }}</td>
26+
<td>${{ bill.total }}</td>
27+
<td>
28+
<button class="btn btn-small" href="#editBill">
29+
<i class="icon-edit"></i>&nbsp;Edit
30+
</button>
31+
</td>
32+
</tr>-->
33+
<tr ng-repeat="bill in bills[0].data | filter:query">
2434
<td>{{ bill.date.monthOfYear }}/{{ bill.date.dayOfMonth}}/{{ bill.date.yearOfCentury}}</td>
2535
<td>{{ bill.title }}</td>
2636
<td>${{ bill.billFinances.billTotal }}</td>
@@ -37,4 +47,4 @@
3747
</div>
3848
</div>-->
3949
<!--<div class="modal hide fade" ng-include="'partials/addBill.html'" id="editModal"></div>-->
40-
<!--{{bills}}-->
50+
<!--{{bills[0].data[0]}}-->

0 commit comments

Comments
 (0)