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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -