I have a unique challenge where I need to utilize the firstkey
from one AngularJS model, firstcollection
, as an index value in another collection called anothercollention
. Essentially, I want to iterate over the values in anothercollention based on the keys of firstcollection using ng-repeat. Although I've searched through various AngularJS documentation, I couldn't find an example that addresses this specific scenario. Most examples assume data is available within the same ng-repeat model.
<ul>
<li ng-repeat="(firstkey, value) in firstcollection"></li>
<ul>
<li ng-repeat="(subkey, subvalue) in anothercollention.firstkey"></li>
<ul>
</ul>
Example
first collection {"fruits": "are the best", "veggies": "are the worst"}
another collection {"fruits": [1, 2, 3], "veggies": [2, 4, 5]},
The HTML rendering should look like this:
fruits are the best
1, 2, 3
veggies are the worst
2, 4, 5