【发布时间】:2018-04-27 21:51:57
【问题描述】:
【问题讨论】:
-
顺便说一句,我看到this 的问题,这是针对旧版本的框架。
【问题讨论】:
如 cmets 中的 @Vega 所示,您不能在 <mat-list-item> 下嵌套 <mat-list>,但如果您 ngFor 另一个包含它们的 div,它仍然可以,并且 <mat-list> 行高是正确的。
这是@Vega 的示例:https://stackblitz.com/edit/angular-nnkg3h-xppmzz
<mat-list>
<ng-container *ngFor="let item of items">
<mat-list-item>{{item.name}}</mat-list-item>
<mat-list style="margin-left:30px;">
<div *ngFor="let subItem of item.subItems">
<mat-list-item>{{ subItem.name }}</mat-list-item>
</div>
</mat-list>
</ng-container>
</mat-list>
【讨论】:
现在有一个 Angular Material“树”组件,它基本上是一个类似于文件结构的嵌套列表列表。如果这是您正在寻找的东西,您可以在这里找到它:https://material.angular.io/components/tree/overview
【讨论】: