可以通过使用Angular材料库中的mat-expansion-panel组件,创建一个具有子面板的扩展面板。下面是一个例子:
在模板文件中,我们可以使用ngFor
指令来循环创建子面板:
{{item.title}}
{{item.description}}
{{item.content}}
在组件文件中,我们可以定义一个items
数组来保存每个子面板的标题、描述和内容:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
items = [
{
title: 'Title 1',
description: 'Description 1',
content: 'Content 1'
},
{
title: 'Title 2',
description: 'Description 2',
content: 'Content 2'
},
{
title: 'Title 3',
description: 'Description 3',
content: 'Content 3'
}
];
}
这样,我们就可以创建一个带有子面板的扩展面板了。