1

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.

1
  • 1
    the checkbox should be <input type=""checkbox" ... > not the <li> and you have to add ng-model="subitem.checked" if you have the checkedproperty like in example Commented Nov 6, 2016 at 2:00

2 Answers 2

2

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>
Sign up to request clarification or add additional context in comments.

Comments

0

The difference is this:

You are using

<li type="checkbox"...

The example uses

<input type="checkbox" ...

Probably what you want is

<li><input type="checkbox" ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.