angularjs - How to set default Radio button in Angular when created with an ng-repeat? -


basically create radio buttons based on items returned server. there not values returned, in case user adds new one:

html:

<tr ng-repeat="item in items">     <td><input type="radio" name="item" ng-model="selected" ng-value="{{item}}" ng-change="getnewotherstuff(item)"/></td> </tr> //close table stuff  <div class="halfmargintop">     <button class="btn btn-success" ng-click="add)">add row</button> </div> 

how set first item in list checked 1 default, when there one?

you init in js controller once received data.

if($scope.items.length > 0) $scope.selected = $scope.items[0]; 

hope helped.


Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -