我有一個簡單的angularJs示例,其中實際上我必須顯示紅色背景以標記正在檢查的收音機框的infront。但是,我無法在input type =「radio」中選擇selected或isChecked屬性,因此我可以根據它添加CSS。在AngularJs中檢查的收音機旁邊的標籤上添加顏色
HTML
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<p ng-repeat="x in questions">
<input type="radio" id="{{x.id}}" name="{{x.name}}"><label for="{{x.id}}">{{x.value}}</label>
</p>
<script>
var app = angular.module("myApp", []);
app.controller('myCtrl',function($scope){
$scope.questions = [
{value:"red",name:"color",id:"1"},
{value:"blue",name:"color",id:"2"},
{value:"yellow",name:"color",id:"3"}
];
});
</script>
</body>
</html>