I have 6 radio buttons. I want 3 on one line and other 3 on another line. I am using ng-repeat for retrieving radio button data from json. I tried putting ng-if for placing it for even and odd but its not working and also used two different div tags bt still not getting. Can anyone help me with this
Asked
Active
Viewed 646 times
-2
-
can u please show what u have tried – Sa E Chowdary Nov 23 '16 at 06:12
-
please add your markup – Geeky Nov 23 '16 at 06:12
-
You can group the data three by three in your controller, then use a nested ng-repeat. – Bünyamin Sarıgül Nov 23 '16 at 06:15
-
check out my answer, I think this is what you are looking for, right? – Farzad Salimi Jazi Nov 23 '16 at 06:54
2 Answers
1
here is a list which can be used also directly in the code. In fact this list can have the radio values.
$scope.list = [0,1,2,3,4,5];
here is the html code :
<div ng-init="list=[0,1,2,3,4,5];">
<div ng-repeat="radio_id in list" ng-if="$index % 3 == 0" class="row">
<div class="col-xs-4" ng-repeat="radio_id in list.slice($index, ($index+3 > list.length ? list.length : $index+3))">
Radio {{radio_id}} <input type="radio" name="radio_id" value="radio_id">
</div>
</div>
</div>

Farzad Salimi Jazi
- 760
- 10
- 25
0
You can use class col-sm-3 on ng-repeat div under row div. If you are using bootstrap.
<div class="row">
<div class="col-sm-12">
<div ng-repeat="a in list" name="chk" class="col-sm-3">
<md-checkbox ng-model="modelName">
<span> {{ room.Name }}</span>
</md-checkbox>
</div>
</div>
</div>

Jenny
- 663
- 4
- 8