【问题标题】:Nested lists in angular material角度材料中的嵌套列表
【发布时间】:2018-04-27 21:51:57
【问题描述】:

你可以在 Angular Material 中嵌套列表吗?

我没有看到任何examples in the documentation

我猜我应该使用multiline list,但我做错了。

Things that I have tried.

【问题讨论】:

标签: angular angular-material2


【解决方案1】:

如 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>

【讨论】:

    【解决方案2】:

    现在有一个 Angular Material“树”组件,它基本上是一个类似于文件结构的嵌套列表列表。如果这是您正在寻找的东西,您可以在这里找到它:https://material.angular.io/components/tree/overview

    【讨论】:

      猜你喜欢
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      相关资源
      最近更新 更多