vitalets / checklist-model

AngularJS directive for list of checkboxes
http://vitalets.github.io/checklist-model
MIT License
1.05k stars 206 forks source link

Not setting radio boxes on load #167

Closed itjustwerks closed 6 years ago

itjustwerks commented 6 years ago

First, this directive is great and has made my life 100x easier when building multi-option checklists. However, I would also like to use this for yes/no, gender, etc radio lists.

It does work to build a set of radio boxes, and changing the selected option does update the model. However, for radio boxes, it doesn't really make sense to store the data in an array. Would it be possible for radio boxes to just store the passed value directly? That could be either an object or a string depending on the data structure passed to checklist-model. On change the directive could just swap the data out completely without even needing to check if it already exists.

Ultimately, I don't mind having to reference the selected radio option by targeting the [0] array item, but for some reason the radio boxes just aren't being set at all when the page loads. They are all unselected, even though the data model looks right. Any thoughts?

Better support for radio boxes would make this directive absolutely perfect!

Thanks!

itjustwerks commented 6 years ago

Got it! You need to set ng-checked="item" on each radio box...