I have an Object with 2 arrays:
mainObject = {
soccer: [],
hockey: []
}
Each of the arrays contain a different amount of objects:
sportObject = {
soccer: [{equipment: "cleats"}, {shirt: "jersey"}, {team: "arsenal"}],
hockey: [{equipment: "skates"}]
}
I print each object onto the page using a list, separated by "sport":
<ul ng-repeat="(sport, value) in sportObject">
<li>{{sport}}</li> // Prints "soccer" or "hockey"
<li ng-repeat="item in sportObject"></li> // <-- one of my failed attempts
</ul>
I want to print each of the object info into an li under the correct sport name.
For example, there are a total of 4 objects, soccer has 3, hockey has 1.
Currently, each item gets repeated under both sports. So both sports have 4, items. How can I use ng-repeat to only print equipment that falls under the correct sport title?
The result should look like:
Soccer
- equipment: cleats
- shirt: jersey
- team: arsenal
Hockey
- equipment: skates
item in sport.