Recursion in Angular directives

前端 未结 9 1611
不思量自难忘°
不思量自难忘° 2020-11-22 04:24

There are a couple of popular recursive angular directive Q&A\'s out there, which all come down to one of the following solutions:

  • manually incrementally \
9条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 04:35

    Now that Angular 2.0 is out in preview I think it's ok to add an Angular 2.0 alternative into the mix. At least it will benefit people later:

    The key concept is to build a recursive template with a self reference:

    • {{ dir.name }}
        {{file}}

    You then bind a tree object to the template and watch the recursion take care of the rest. Here is a full example: http://www.syntaxsuccess.com/viewarticle/recursive-treeview-in-angular-2.0

提交回复
热议问题