1

I am able to do something similar everywhere else, but not with checkboxes. What am I missing here?

My json looks like this:

{
"data": [
     {
        "id": 1,
        "tags": [
            "tag1",
            "tag2"
        ],
        ...a bunch of other stuff...
    },
    {
        "id": 2,
        "tags": [
            "tag1",
            "tag2",
            "tag3",
            "tag4"
        ],
        ...a bunch of other stuff...
    }
 ]
 }

And my HTML (Angular) looks like this:

<div ng-repeat="tag in ::vm.media.tags track by $index">
     <md-checkbox >
         {{tag.tags}}
     </md-checkbox>
</div>

I am having a hard time getting the actual text or name of the tags to show next to the checkbox. ALl I am getting is the checkboxes alone as the image shows below

enter image description here

Thanks in advance

8
  • It is working fine. codepen.io/next1/pen/YNMLjd Commented Feb 16, 2017 at 19:34
  • Not quite. Each tag is its own checkbook. That's why the ng repeat is different in my code than yours Commented Feb 16, 2017 at 19:38
  • you want checkbox for each tag in data ? Commented Feb 16, 2017 at 19:40
  • Correct :). There are several items and each has different tags and amount of tags. The ng repeat should display all tags for that particular item with a checbox Commented Feb 16, 2017 at 19:42
  • check the updated codepen Commented Feb 16, 2017 at 19:45

1 Answer 1

1

You just need to use one more ng-repeat to iterate all the tags for each data item. Here is the code.

<div ng-repeat="data in data.data" layout="column">
 <span> ID: {{data.id}}</span>
 <md-checkbox ng-repeat="eachTag in data.tags">
  {{eachTag}}
 </md-checkbox>
</div>

Here is the working Codepen.

Sign up to request clarification or add additional context in comments.

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.