I have an object with 2 arrays:
mainObject = { soccer: [], hockey: [] }
Each of the arrays contains a different number of objects:
sportObject = { soccer: [{equipment: "cleats"}, {shirt: "jersey"}, {team: "arsenal"}], hockey: [{equipment: "skates"}] }
I print each object on 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 every object information in li
under the correct sport name.
For example, there are a total of 4 objects, football has 3, hockey - 1.
Currently, each subject is repeated under both sports. Thus, both sports have 4 items. How can I use ng-repeat only to print equipment that falls under the correct sports title?
The result should look like this:
Football
- equipment: spikes
- shirt: shirt
- team: arsenal
Hockey
source share