Reputation: 100
Here is the code on selection of any one of the radio button i need to get the value
<label ng-repeat="SurveyType in SurveyTypes">
<input type="radio" name="SurveyTypeName" ng-model="surveyData.SurveyTypeName" ng-value="{{surveyData.SurveyTypeName}}" />
{{SurveyType.Name}}
</label>
Upvotes: 0
Views: 1280
Reputation: 16805
You should assign value
from your repeat-loop
not from model
value and no need to use {{}}
for ng-value
so use ng-value="SurveyType.Name"
instead of ng-value="{{surveyData.SurveyTypeName}}"
so selected radio button value set to surveyData.SurveyTypeName
.
If you want to select anyone by default you can assign value to surveyData.SurveyTypeName
like $scope.surveyData={SurveyTypeName: 'second'}
then that radio button shown as selected that has value second
.
HTML:
<label ng-repeat="SurveyType in SurveyTypes">
<input type="radio" name="SurveyTypeName" ng-model="surveyData.SurveyTypeName" ng-value="SurveyType.Name" />
{{SurveyType.Name}}
</label>
Upvotes: 1
Reputation: 8346
Don't know from surveyData.SurveyTypeName
is coming from.
<li ng-repeat="SurveyType in SurveyTypes">
<input type="radio" name="SurveyTypeName" ng-model="$parent.rdoSelected" ng-value="SurveyType.SurveyTypeName" />
{{SurveyType.Name}}
</li>
Upvotes: 0
Reputation: 15292
Your HTML should be like this.
<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
}
Upvotes: 0