How to create dynamically radio button and checkbox?

Hello Sir,

I want create list divider . one divider will be radio group and other divider will be checkbox. Checkbox and Radio button will creat from controller.

My code is Bellow:
$scope.burgerList = [
{id:1, title:‘Buger 1’, type:‘radiobutton’},
{id:1, title:‘Buger 1’, type:‘radiobutton’},
{id:1, title:‘Buger 1’, type:‘checkBox’},
{id:1, title:‘Buger 1’, type:‘checkBox"’}
]

if type is radiobutton, dynamicallycreate radio button. if type is checkBox, dynamically create radio button.

How to do it in a list ?
Please help me…

1 Like

Hi,

Try this:

say you have a burgerList
$scope.burgerList=[ {id:0, title:'burger1';type:'radio'}, {id:1, title:'burger2';type:'radio'}, {id:2, title:'burger3';type:'check'} ]

to repeat this with just a radioButton you can just do this:
<ion-list> <ion-radio ng-repeat="burger in burgerList" ng-model="choice" ng-value="burger.id">{{burger.title}}</ion-radio> </ion-list>
where $scope.choice contains the selected burger id.

To generate dynamic radiobuttons or checkboxes I would go for the ng-if option:

`

{{burger.title}} {{burger.title}}
`

good luck

1 Like

Working nice.
Thanks a lot…

2 Likes