javascript - Get value of checked radio button in radio button in Angular JS which as ng-repeat -
here code on selection of 1 of radio button need value
<label ng-repeat="surveytype in surveytypes"> <input type="radio" name="surveytypename" ng-model="surveydata.surveytypename" ng-value="{{surveydata.surveytypename}}" /> {{surveytype.name}} </label>
you should assign value
repeat-loop
not model
value , no need use {{}}
ng-value
so use ng-value="surveytype.name"
instead of ng-value="{{surveydata.surveytypename}}"
selected radio button value set surveydata.surveytypename
.
if want select default can assign value surveydata.surveytypename
$scope.surveydata={surveytypename: 'second'}
radio button shown selected 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>
Comments
Post a Comment