如何在角度6中制作类别树?这样所有的孩子(各个层次)

时间:2019-07-11 13:57:53

标签: typescript web-services angular6

我在Web Service-WCF中有一个类别树,按所有级别排序。 每个类别都有三个组成部分:

  1. ID(int)
  2. 名称(字符串)
  3. ParenID(int?)

我希望这棵树也以打字稿出现在Angular 6一侧。

这是component.htm文件:

<div class="categories">
        <div *ngFor="let category of categories">
          <h6>{{category.Name}}-<label > წიგნების რაოდენობა {{category.BookCount}}</label> </h6>
          <ul>
            <ng-template #recursiveList let-list>
              <li *ngFor="let subCategory of list">
                <div>{{subCategory.Name}}- <label > წიგნების რაოდენობა {{subCategory.ChildBookCount}}</label></div>
                <ul *ngIf="subCategory.ChildCategory?.length > 0">

                  <ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: subCategory.ChildCategory }"></ng-container>
                </ul>
              </li>
            </ng-template>

            <ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: category.ChildCategory }"></ng-container>
          </ul>
        </div>
      </div>

0 个答案:

没有答案
相关问题