Javascript 验证是否在submit:AngularJs页面中选中了单选按钮

Javascript 验证是否在submit:AngularJs页面中选中了单选按钮,javascript,angularjs,Javascript,Angularjs,我对AngularJS是新手。我使用工厂向dom提出了一些问题。我必须验证是否选中了单选按钮。请给出改进此代码的建议 Index.html <body ng-app="quiz"> <div id="container" ng-controller="QuizController"> <button ng-click="submitfun()">submit</button> </div> <

我对AngularJS是新手。我使用工厂向dom提出了一些问题。我必须验证是否选中了单选按钮。请给出改进此代码的建议

Index.html

<body ng-app="quiz">
    <div id="container" ng-controller="QuizController"> 
        <button ng-click="submitfun()">submit</button>
    </div>  
</body>
factory.js

angular.module('quiz', ['quiz.service','quiz.directive']);

var QuizController = function($scope, questionFactory) {
    $scope.questions_and_answers = questionFactory;
    $scope.checkList=[];    
    $scope.submitfun= function(message){
        alert('hi');         
    }   
};
angular.module('quiz.service', [])
    .factory('questionFactory', function() {
        return [
            { question: "Which of these is England's official slogan for the World Cup?", answerChoices: [ "Impossible is not an English word", "One nation, one team, one dream!", "Real men wear red and white","The dream of one team, the heartbeat of millions!!" ] },
            { question:"Who was Roy Keane talking this week about when he said: \"Not everybody wants to wander around the pitch waving and crying?\" ", answerChoices:["David Moyes","John Terry","Luis Suárez","Rio Ferdinand"]}
        ];
});

您可以结合使用ng disabled和ng show指令来验证和显示错误消息


参见此

单选按钮在哪里?