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
Post a Comment