默認情況下,我在選擇單選按鈕時遇到問題。檢查ng-repeat中多個單選按鈕的值
以下是我的JSON數據
var Result = [{
"Questions": [{
"Question": "question1",
"Answer": "Yes"
},
{
"Question": "question2",
"Answer": "No"
},
{
"Question": "question3",
"Answer": null
}]
},
{
"Questions": [{
"Question": "question1",
"Answer": "Yes"
},
{
"Question": "question3",
"Answer": "No",
},
{
"Question": "question4",
"Answer": null,
}]
}];
有了這個JSON數據,我需要選擇基於答案的單選按鈕。
<div ng-repeat="item in Result">
<div class="col-xs-12" ng-repeat="question in item.Questions">
<div class="input-group col-xs-12">
<div>{{question.Question}}</div>
<div>
<span class="col-xs-4 col-sm-4 no-padding"><input type="radio" ng-model="question.Answer" name="questions_{{$parent.$index}}_{{$index}}" ng-checked='question.Answer == "Yes"' /> <span>Yes</span></span>
<span class="col-xs-4 col-sm-4 no-padding"><input type="radio" ng-model="question.Answer" name="questions_{{$parent.$index}}_{{$index}}" ng-checked='question.Answer == "No"' /> <span>No</span></span>
</div>
</div>
</div>
</div>
我無法做到這一點。任何人都可以讓我知道我做錯了什麼嗎?
我認爲你的輸入數據有問題。檢查JSON。改變你的需要。 –
它應該如何工作? – user1268130
你能否清楚輸出應該如何。所以我也可以幫助 –