Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ "Players":{
- "R" : 0,
- "Team" : "Industry",
- "Y" : 0,
- "assists" : 0,
- "goals" : 20,
- "id" : 1,
- "image" : "http://res.cloudinary.com/deji/image/upload/v1509140819/industry.jpg_ballers_khc5fy.jpg",
- "name" : "Fabio",
- "position" : "midfielder",
- "price" : 6000000
- }, {
- "R" : 0,
- "Team" : "Industry",
- "Y" : 0,
- "assists" : 0,
- "goals" : 8,
- "id" : 2,
- "image" : "http://res.cloudinary.com/deji/image/upload/v1509140819/industry.jpg_ballers_khc5fy.jpg",
- "name" : "Hassan 'Hasi' Akinyera",
- "position" : "defender",
- "price" : 5000000
- },
- "users" : {
- "5UBG3yqWnRXe05bByUeASYVbY0l1" : {
- "email" : "john@gamail.com",
- "fullname" : "123456",
- "teamname" : "123456",
- "total" : [ 1, 2, 3, 4, 5, 6 ],
- "userName" : "john@gamail.com",
- "week" : 0
- },
- "AotYBSfTDBhl7vbeWK7WFUh9s3i1" : {
- "email" : "vanessa@yahoo.com",
- "fullname" : "123456",
- "teamname" : "123456",
- "total" : [ 1, 2, 3, 4, 5, 6 ],
- "userName" : "vanessa@yahoo.com",
- "week" : 0
- },
- "l3J1TVsFNLMi0Oxg6hz4AJpacE53" : {
- "email" : "awoniyideji@yahoo.com",
- "fullname" : "Djflex11",
- "teamname" : "deji awoniyi",
- "total" : [ 1, 1, 5 ],
- "userName" : "awoniyideji@yahoo.com",
- "week" : "no"
- }
- }
- ]
- $firebaseArray(Players)
- .$loaded(function(loadedPlayers) {
- var normalizedPlayers = loadedPlayers.reduce(function(acc, next) { acc[next.id] = next; return acc; }, {});
- var selectedPlayers = $scope.pick.map(function(num){
- return normalizedPlayers[num];
- });
- $scope.players = selectedPlayers;
- $scope.sum = function(items, prop){
- return items.reduce( function(a, b){
- return a + b[prop];
- }, 0);
- };
- $scope.totalPoints = $scope.sum('Players', 'goals');
- userRef.set($scope.totalPoints);
- });`
Add Comment
Please, Sign In to add comment