JSFiddle - React, Tailwind, and code Playground

by legolandbridge

HTML

<div ng-app ng-controller="AppCtrl">
    <button ng-click="getWinner()">Get Winner of Match 1</button><br />
    Match 2:<br />
    {{ match2.p1 }} vs {{match2.p2}}
   
</div>

JavaScript

function AppCtrl($scope) {
    $scope.match1 = { // p1 vs p2 
       p1: "Player A",
       p2: "Player B",
       winner: "to be determined"
    };
    $scope.match2 = {
       p1: $scope.match1.winner,
       p2: "Player C",
       winner: "to be determined"
    };

    $scope.getWinner = function() { //on click
        $scope.match1.winner = "Player B";
        console.log($scope.match2.p1); //value is not updated
    };
    
    
}