I have a tree like data structure
{
name: "name 1",
childs: [
{
name: "name 1.1",
childs: [
{
name: "name 1.1.1",
childs: []
},
{
name: "name 1.1.2",
childs: [
{
name: "name 1.1.2.1",
childs: []
}
]
},
{
name: "name 1.1.3",
childs: []
}
]
},
{
name: "name 1.2",
childs: [
{
name: "name 1.2.1",
childs: []
}
]
},
{
name: "name 1.3",
childs: [ ]
}
]
}
]
and I want to visualize it as cascaded List like this
<ul>
<li>name 1
<ul>
<li>name 1.1
<ul>
<li>name 1.1.1</li>
<li>name 1.1.2
<ul>
<li>1.1.2.1</li>
</ul>
</li>
<li>name 1.1.3</li>
</ul>
</li>
<li>name 1.2
<ul>
<li>name 1.2.1</li>
</ul>
</li>
<li>name 1.3</li>
</ul>
</li>
</ul>
The problem is, my data structure is not fix. So I will need to create my HTML output recursive, but I have no idea how to do this in angular. In this case a simple *ngfor won’t be enough. Is there an angular mechanism that I can use to solve this problem? Or has anyone a clue how I can handle the problem?