2

I have sections that belong to a report like so:

{
    "id": 2,
    "order": 0,
    "report": 2,
    "title": "Why winters suck",
    "content": "<p>content here</p>\r\n",
    "children": [
        {
            "id": 3,
            "order": 1,
            "report": 2,
            "title": "Lol winters are terrible",
            "content": "<p>very bad</p>\r\n",
            "children": []
        }
    ]
},

As you can see, a section can have an infinite number of children any number of levels deep. I want to be able to display them all nested under eachother. Currently I have something that looks like this:

<div ng-class="{active: isSelectedSection(section.id)}"  ng-repeat="section in sections | filter:{report:currentReport.id}">
                    {{section.title}}
</div>

Which only displays the 1st level reports. How can I have it so that it displays the child sections as well?

  • I would flatten the hierarchy using a recursive function and iterate over the flattened list. – Frode Nov 29 '15 at 22:05

0 Answers0