JSFiddle - React, Tailwind, and code Playground

by spring1975

HTML

<script src="http://code.angularjs.org/1.0.6/angular.js"></script>
<div ng-app>
    <div ng-controller="TestController">
        {{question1 | json}}
        <div>
            <label data-ng-repeat="choice in question1.choices">
                <input type="radio" name="response" value="{{choice.id}}" ng-model="question1.userChoice"/>
                    {{choice.text}}
            </label>
        </div>
        <div>
            <label data-ng-repeat="choice in question2.choices">
                <input type="radio" name="response" data-ng-model="choice.isUserAnswer" value="true" />
                    {{choice.text}}
            </label>
        </div>
    </div>
</div>

JavaScript

function TestController($scope) {
    $scope.question1 = {
        questionText: "This is a test question.",
        choices: [{
                id: 1,
                text: "Choice 1",
                isUserAnswer: "false"
            }, {
                id: 2,
                text: "Choice 2",
                isUserAnswer: "true"
            }, {
                id: 3,
                text: "Choice 3",
                isUserAnswer: "false"
            }],
      userChoice: 2
    };   
    
    $scope.question2 = {
        questionText: "This is a test question.",
        choices: [{
            id: 1,
            text: "Choice 1",
            isUserAnswer: false
        }, {
            id: 2,
            text: "Choice 2",
            isUserAnswer: true
        }, {
            id: 3,
            text: "Choice 3",
            isUserAnswer: false
        }]
    };   
}