Guest User

Untitled

a guest
Nov 16th, 2017
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. [ "Players":{
  2. "R" : 0,
  3. "Team" : "Industry",
  4. "Y" : 0,
  5. "assists" : 0,
  6. "goals" : 20,
  7. "id" : 1,
  8. "image" : "http://res.cloudinary.com/deji/image/upload/v1509140819/industry.jpg_ballers_khc5fy.jpg",
  9. "name" : "Fabio",
  10. "position" : "midfielder",
  11. "price" : 6000000
  12. }, {
  13. "R" : 0,
  14. "Team" : "Industry",
  15. "Y" : 0,
  16. "assists" : 0,
  17. "goals" : 8,
  18. "id" : 2,
  19. "image" : "http://res.cloudinary.com/deji/image/upload/v1509140819/industry.jpg_ballers_khc5fy.jpg",
  20. "name" : "Hassan 'Hasi' Akinyera",
  21. "position" : "defender",
  22. "price" : 5000000
  23. },
  24. "users" : {
  25. "5UBG3yqWnRXe05bByUeASYVbY0l1" : {
  26. "email" : "john@gamail.com",
  27. "fullname" : "123456",
  28. "teamname" : "123456",
  29. "total" : [ 1, 2, 3, 4, 5, 6 ],
  30. "userName" : "john@gamail.com",
  31. "week" : 0
  32. },
  33. "AotYBSfTDBhl7vbeWK7WFUh9s3i1" : {
  34. "email" : "vanessa@yahoo.com",
  35. "fullname" : "123456",
  36. "teamname" : "123456",
  37. "total" : [ 1, 2, 3, 4, 5, 6 ],
  38. "userName" : "vanessa@yahoo.com",
  39. "week" : 0
  40. },
  41. "l3J1TVsFNLMi0Oxg6hz4AJpacE53" : {
  42. "email" : "awoniyideji@yahoo.com",
  43. "fullname" : "Djflex11",
  44. "teamname" : "deji awoniyi",
  45. "total" : [ 1, 1, 5 ],
  46. "userName" : "awoniyideji@yahoo.com",
  47. "week" : "no"
  48. }
  49. }
  50. ]
  51.  
  52. $firebaseArray(Players)
  53. .$loaded(function(loadedPlayers) {
  54. var normalizedPlayers = loadedPlayers.reduce(function(acc, next) { acc[next.id] = next; return acc; }, {});
  55. var selectedPlayers = $scope.pick.map(function(num){
  56. return normalizedPlayers[num];
  57. });
  58. $scope.players = selectedPlayers;
  59.  
  60. $scope.sum = function(items, prop){
  61. return items.reduce( function(a, b){
  62. return a + b[prop];
  63. }, 0);
  64. };
  65.  
  66. $scope.totalPoints = $scope.sum('Players', 'goals');
  67. userRef.set($scope.totalPoints);
  68.  
  69. });`
Add Comment
Please, Sign In to add comment