单位为ng-repeat的单选按钮的默认选定对象值

时间:2016-07-19 16:13:59

标签: angularjs html5

我希望从

中的单选按钮默认选定的对象值
ng-repeat. `checkbox is working fine.` 

我的Html

<tr ng-repeat="question  in Questions" ng-init="Pindex = $index">
                            <td ng-if="question.answerKeyModel.length <= 0" colspan="3"><strong>{{question.Question}}</strong></td>
                            <td ng-if="question.answerKeyModel.length > 0 && question.IsGroupQuestion !=true" class="pad-L20">{{question.Question}}</td>
                            <td ng-if="question.answerKeyModel.length > 0 && question.IsGroupQuestion ==true"><strong>{{question.Question}}</strong></td>
                            <td align="center" ng-repeat="answerKey in question.answerKeyModel">
                                <div ng-if="question.Type=='checkbox'" class="check_box">
                                    <input type="checkbox" name="checkbox{{Pindex}}{{$index}}" id="checkbox{{Pindex}}{{$index}}"
                                           ng-true-value="{{answerKey}}" ng-false-value=""
                                           ng-model="question.Answer[$index]" ng-value="answerKey" />
                                    <label for="checkbox{{Pindex}}{{$index}}">&nbsp;</label>
                                </div>
                                <div ng-if="question.Type=='radio'" class="radio_box">
                                    <input type="radio" name="Answer{{Pindex}}" id="radio{{Pindex}}{{$index}}"
                                           ng-model="question.Answer[0]" ng-value="answerKey" />
                                    <label for="radio{{Pindex}}{{$index}}">&nbsp;</label>
                                </div>
                            </td>
                        </tr>

我的控制器是

OpiodRiskToolFactory.GetQuestions($state.current.name, PatientInfo.Id).then(function (data) {
        $scope.Questions = data;
    });

我不想在控制器中做额外的工作

0 个答案:

没有答案