0
我試圖做一個TreeView在我component.html模板遞歸這是我的代碼:角2 - 不工作
<div *ngFor="let item of menusList">
<div class="containerMenu">
<span [ngClass]="{collapseTitle:item.SubItems.length}">
<i [ngClass]="item.SubItems.length ? 'fa fa-angle-down' : ''"></i>
<span style="display:inline-block">
<span>{{item.Title.Traductions.French}}</span>
</span>
</span>
<div *ngIf="item.SubItems.length" ng-include="'menu'" class="collapsePanel"></div>
</div>
</div>
<!--Submenu Template + Récursive-->
<ng-template #menu>
<ul>
<li *ngFor="let item of item.SubItems">
<span ng-if="!item.Url" ng-class="{collapseTitle:item.SubItems.length}">
<i ng-class="item.SubItems.length ? 'fa fa-angle-down' : ''"></i>
<span ng-class="item.SubItems.length ? 'subItemsTitle' : ''">
<span style="display:inline-block">
<span>{{item.Title.Traductions.French}}</span>
</span>
</span>
</span>
<a target="_blank" href="{{item.Url}}" ng-if="item.Url">
<span ng-class="item.SubItems.length ? 'collapseTitle' : ''">
<i ng-class="item.SubItems.length ? 'fa fa-angle-down' : ''"></i>
<span ng-class="item.SubItems.length ? 'subItemsTitle' : ''">
<span style="display:inline-block">
<span>{{item.Title.Traductions.French}}</span>
</span>
</span>
</span>
</a>
<div *ngIf="item.SubItems.length" ng-include="'menu.html'" class="collapsePanel"></div>
</li>
</ul>
</ng-template>
所以,我的第一個div交我所有的陣列(menusList),如果當前位置有子項,它應該包含模板#菜單。這是在AngularJS中工作,但我想在Angular2中完成。
我沒有錯誤在我的控制檯,我想我的問題是ng-include
感謝您的幫助。