Last active
June 15, 2021 13:47
-
-
Save maximLyakhov/0331d7c831b880f549b2785203c2e054 to your computer and use it in GitHub Desktop.
angular recursive ngFor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<ng-container *ngTemplateOutlet="recursiveList; context: { list: dataSource.data }"></ng-container> | |
</ul> | |
<ng-template #recursiveList let-list="list"> | |
<li *ngFor="let item of list"> | |
<div *ngIf="item"> | |
{{ item | json }} | |
<span> | |
{{ item.name }} | |
</span> | |
<ul *ngIf="item.children && item.children.length > 0"> | |
<ng-container *ngTemplateOutlet="recursiveList; context: { list: item.children }"></ng-container> | |
</ul> | |
</div> | |
</li> | |
</ng-template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment