最简单的方法是创建通用部分,以便您可以使用递归调用和呈现它
ng-include。
<div ng-include="'partialComment.html'" ng-model="comments"></div>
这是局部的:
<ul> <li ng-repeat="c in comments"> {{c.text}} <div ng-switch on="c.comments.length > 0"> <div ng-switch-when="true"> <div ng-init="comments = c.comments;" ng-include="'partialComment.html'"></div> </div> </div> </li></ul>数据模型应为列表
var comments = [{ ... }]。我为您创建了一个演示,希望对您有所帮助。
**[Demo](http://plnkr.co/edit/SqIzbR6Rgi5qbnAocFf5?p=preview)**



