繁体   English   中英

如何以角度扩展/折叠多个面板?

[英]How to expand/collapse multiple panels in angular?

如何一次扩展多个手风琴(面板)项目。 展开/折叠动作也可以通过再次单击来切换。

Categories.html

<ul class="treeChildren"  *ngFor="let department of getAllDepartments; let i=index">
    <li class="treeChildrenItems">
        <div class="moduleListData" >
            <i (click)="showCategory(i);" [ngClass]="{'fa-caret-down': 'i == categoryIndex', 'fa-caret-right': 'i != categoryIndex'}" class="fa" ></i>
            <strong class="categoryName">{{department.departmentName}}</strong>
        </div>
  </li>
</ul>

category.compenent.ts

// Currently its working for single panel Expand/Collapse
categoryIndex : Number ;
  showCategory(index){
    if (this.categoryIndex == index) {
      this.categoryIndex = NaN;
    } else {
      this.categoryIndex = index
    }
  }

图片链接: https : //i.imgur.com/uvQ9BYr.png

<ul class="treeChildren"  *ngFor="let department of getAllDepartments; let i=index">
    <li class="treeChildrenItems">
        <div class="moduleListData" >
            <i (click)="department.expanded != department.expanded" [ngClass]="{'fa-caret-down': department.expanded, 'fa-caret-right': !department.expanded }" class="fa" ></i>
            <strong class="categoryName">{{department.departmentName}}</strong>
        </div>
  </li>
</ul>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM