6

JSFiddle

I'm not able to access the array images in the nested collection. Why am I not able to see any output?

The model:

var obj = [{
    "id": "7",
    "date": "1 Jan",
    "images": ["507f42c682882", "507e24b47ffdb", "507e2aeca02d5", "507e2b19663a9"]
}, {
    "id": "7",
    "date": "1 Jan",
    "images": ["507f42c682882", "507e24b47ffdb", "507e2aeca02d5", "507e2b19663a9"]
}];

This is the HTMl with ng-repeat:

<ul>
    <li ng-repeat="img in item"> 
        <br /> 
        <li ng-repeat="img1 in img.images">{{img1}}</li>
    </li>
</ul>

Can anyone point me to what I'm missing?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Sankar S
  • 98
  • 1
  • 1
  • 4

1 Answers1

10

The problem is you are trying to repeat a list of li elements inside of a li element, which is invalid HTML. As such, angular will not render this.

Update your HTML to:

<ul>
    <li ng-repeat="img in item"> 
        <ul>
            <li ng-repeat="img1 in img.images">{{img1}}</li>
        </ul>
    </li>
</ul>
thomaux
  • 19,133
  • 10
  • 76
  • 103
  • 2
    Of course if u didn't want nested uls you are screwed – Sam Aug 01 '14 at 05:34
  • 1
    You'll need to find another approach if you want to render a flat list, that's true. Either by changing your HTML structure or by flattening the input array – thomaux Aug 01 '14 at 06:16