以下是选择我需要获取值
的任何一个单选按钮的代码<label ng-repeat="SurveyType in SurveyTypes">
<input type="radio" name="SurveyTypeName" ng-model="surveyData.SurveyTypeName" ng-value="{{surveyData.SurveyTypeName}}" />
{{SurveyType.Name}}
</label>
答案 0 :(得分:1)
您应该从value
分配repeat-loop
而不是model
分配{{}}
而不需要ng-value
ng-value="SurveyType.Name"
因此请使用ng-value="{{surveyData.SurveyTypeName}}"
代替surveyData.SurveyTypeName
,以便将所选的单选按钮值设置为surveyData.SurveyTypeName
。
如果您希望默认选择任何人,则可以将值$scope.surveyData={SurveyTypeName: 'second'}
分配给second
,然后选择显示为选中且值为<label ng-repeat="SurveyType in SurveyTypes">
<input type="radio" name="SurveyTypeName" ng-model="surveyData.SurveyTypeName" ng-value="SurveyType.Name" />
{{SurveyType.Name}}
</label>
的单选按钮。
<强> HTML:强>
category
答案 1 :(得分:0)
您的HTML应该是这样的。
<input type="radio" name="SurveyTypeName" ng-model="surveyData.SurveyTypeName" ng-value="{{surveyData.SurveyTypeName}}" ng-change="getval($index)"/>
的js
$scope.getval = function (index){
var servetypename =SurveyTypes[index];
var data =servetypename.SurveyTypeName
}
答案 2 :(得分:0)
来自surveyData.SurveyTypeName
的不知道来自。
<li ng-repeat="SurveyType in SurveyTypes">
<input type="radio" name="SurveyTypeName" ng-model="$parent.rdoSelected" ng-value="SurveyType.SurveyTypeName" />
{{SurveyType.Name}}
</li>