Seeking clarification on a somewhat ambiguous question. To provide context, I am extracting the following JSON data:
{
items: [
{ name: "item 1", options: [1, 2, 3] },
{ name: "item 2", options: [2, 3] },
{ name: "item 3", options: [1] }
],
options: [
{ id: 1, color: "red" },
{ id: 2, color: "blue" },
{ id: 3, color: "yellow" }
]
}
I'm using ng-repeat to iterate over the items as shown below:
<div data-ng-repeat="item in items">
<span>{{ name }}</span>
<ul>
<li data-ng-repeat="i in item.options">{{i}}</li>
</ul>
</div>
My intention is to access additional parameters like 'color' within my second ng-repeat loop instead of just numbers. What would be the most effective approach to achieve this? Should I map the options array for each item during initialization to convert each index into the complete object (containing id and color)? Or should I pass the index to the controller, perform a lookup, and then expand the scope with the retrieved option?