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}} &nbsp; &nbsp; &nbsp; </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}} &nbsp; &nbsp; &nbsp; </label> 

plunker demo


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -