根据您的个性需求进行定制 先人一步 抢占小程序红利时代
注意到在一组radio中,使用的ng-model是一样的,原理与name类似,ng-model的值与js的数组直接绑定(通过$index来确定具体绑定到哪个 )。
js代码如下:
app.controller('QuestionSettingCtrl',function($scope, $http){ $scope.answer = new Array(30); $http({ url : "/getexamquestions", method : "post", params : { 'account' : 30 } }).success(function(res){ $scope.items=res; }); $scope.submit = function(){ $http({ url : "/submitanswer", method : "post", params : { 'answer' : $scope.answer } }).success(function(res){ alert("你做对了"+res+"题!"); }); } });
上述内容就是怎么在angularjs中使用ng-repeat实现单选框,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。