Mpondomise Mpondomise - 9 months ago 70
AngularJS Question

angularjs nested ng-repeat of checkbox

I have the following ng-repeat list. I want to convert it to checkboxes.

Currently, it is repeating the category headings in myJSON.mylist and then repeating each subitem in each category in list mode.

How can I convert the list type into checkbox type, so that ONLY subitems can be chosen?

<ul ng-repeat="s in myJSON.mylist">
<li type="checkbox"> {{s.item}}</li>
<ul >
<li type="checkbox" ng-repeat="subitem in s.subitems">
{{subitem.values}}</li>
</ul>
</ul>


here is a similar example.

AHC AHC
Answer Source

you can go like this:

<div ng-repeat="sin myJSON.mylist">
    <div > {{s.item}}</div>
    <ul >
        <li ng-repeat="subitem in s.subitems">
            <input type="checkbox" name="myname"
                   ng-model="myModel.myname[subitem.values]">
                    {{subitem.values}}
        </li>
    </ul>
</div>