JSFiddle - React, Tailwind, and code Playground

by Fareez Ahmed

JavaScript

angular.module('FFTrades.tradeanalyzer', [])

.controller('TradesController', function($scope, TradesDataFactory) {

    $scope.teams = [

    ];
    $scope.data = {};
    $scope.selectedItem1 = 0;
    $scope.selectedItem2 = 0;


    var membersAndUpvotesObject = {
        members: [],
        upvotes: 0
    };

    //need to convert them to their keys before pushing. 

    $scope.getPlayerData = function() {
        // getting this from the services.
        TradesDataFactory.getPlayerInfo().then(function(playerInfo) {
            $scope.data.playerInfo = playerInfo;
            //console.log($scope.data.playerInfo);
            //["Matt Forte : 17", "Anderson : 16", "Jamaal Charles : 16", "Eddie Lacy : 15", "Andre Ellington : 14", "LeSean McCoy : 14", "Marshawn Lynch : 14", "Tre Mason : 13", "Latavius Murray : 13", "Rashad Jennings : 12", "Alfred Morris : 12", "Jonathan Stewart : 12", "Doug Martin : 12", "Chris Ivory : 12"]
        }).catch(function(error) {
            //console.error(error)
        })
    }


    $scope.calc = function() {
        $scope.calculatedValue1 = Number($scope.data.playerInfo[$scope.selectedItem1]);

        if ($scope.selectedItem2) {
            $scope.calculatedValue1 = Number($scope.data.playerInfo[$scope.selectedItem1]) + Number($scope.data.playerInfo[$scope.selectedItem2]);
            membersAndUpvotesObject.members.push($scope.selectedItem1, $scope.selectedItem2);
        }
        //so now I have the team 1 selection stored in an array.

    }



    $scope.calc2 = function() {
        $scope.calculatedValue2 = Number($scope.data.playerInfo[$scope.selectedItem3]);

        if ($scope.selectedItem4) {

            $scope.calculatedValue2 = Number($scope.data.playerInfo[$scope.selectedItem3]) + Number($scope.data.playerInfo[$scope.selectedItem4]);
            membersAndUpvotesObject.members.push($scope.selectedItem3, $scope.selectedItem4);
            //$rootScope.nested.push(upvotes);
        };
        //team 2 selection...