Angular Material 7 – 列表
<mat-list>
是一个Angular指令,用于创建并格式化一系列项目的容器。
在本章中,我们将演示使用Angular Material绘制列表控件所需的配置。
创建Angular应用程序
按照以下步骤更新我们在 Angular 6 – 项目设置 章节中创建的Angular应用程序 −
步骤 | 描述 |
---|---|
1 | 如 Angular 6 – 项目设置 章节中所述,创建一个名为 materialApp 的项目。 |
2 | 修改 app.module.ts 、 app.component.ts 、 app.component.css 和 app.component.html ,如下所述。保持其余文件不变。 |
3 | 编译并运行应用程序,验证实现逻辑的结果。 |
以下是修改后的模块描述符 app.module.ts 的内容。
以下是修改后的HTML宿主文件 app.component.html 的内容。
结果
验证结果。
详情
- 首先,我们使用mat-list创建了列表。
- 然后,我们使用mat-list-item添加了内容。