我需要有可能将可能的无限深层阵列结构打印到列表中。这是来自修改后的AngularJS示例的代码,其中我在数组中添加了一些更深的子代。如何打印child of child
甚至是其子女?只要有更多的孩子,我有没有办法让它永远重复?
HTML
<div ng-app>
<div ng-controller="TodoCtrl">
<ul>
<li ng-repeat="todo in todos">
<span>{{todo.text}}</span>
<ul>
<li ng-repeat="child in todo.children">
<span>{{child.text}}</span>
<!-- What about the next one -->
</li>
</ul>
</li>
</ul>
</div>
</div>
JS
function TodoCtrl($scope) {
$scope.todos = [{
text: 'root 1',
children: [{
text: 'child of root 1',
children: [{
text: 'child of child',
children: []
}]
}]
}, {
text: 'root 2',
children: []
}];
}