Fabdrol
Fabdrol

Reputation: 738

AngularJS: nested ng-repeat (array in object) only works if there is one item in array, not when multiple

Okay, I have a weird issue. I have an array of objects. Each object contains another array (of strings). I loop over the array of objects using ng-repeat. Within the repeated code I ng-repeat over the array of strings. For some reason, this nested ng-repeat only works when the array of strings contains but one (1) item. When there are more items, it simply doesn't work.

Code

Result of <pre>{{ answer.value | json }}</pre>

[
  "Apothekerskast",
  "Apothekerskast",
  "Koelkast ombouw"
]

The view (in a gist because posting here causes issues with markdown): https://gist.github.com/fabdrol/898e4ac9760fc358ce81

The data (in JSON), for easy reading: https://gist.github.com/fabdrol/089467fa09dad6e89e81

Upvotes: 2

Views: 780

Answers (1)

Ivan Chernykh
Ivan Chernykh

Reputation: 42186

It doesn't like duplicates, use track by $index:

ng-repeat="val in vals track by $index"

JSFiddle: http://jsfiddle.net/nedq13q2/

Upvotes: 3

Related Questions