【发布时间】:2024-05-19 17:40:02
【问题描述】:
我正在使用 Angular 7 和 Angular 材质。
我有一个选项卡和一个选择列表,我希望选择列表中显示的值取决于选项卡组上的选择。
不确定实现这一点的最佳方法是什么,我在想一个函数,它可以从字面上创建一个新列表,接收数据中的 2 个列表和共同的属性作为参数。
我的标签组几乎充满了字母 然后我会将字母作为属性添加到列表对象中。
有没有更好的方法来做到这一点?
我的代码如下所示: (html)
<mat-tab class="error-label mat-tab-labels-errors" *ngFor="let areaItem of areaList, let i = index"
<mat-list-option *ngFor="let err of errors" [value]="err.id">
(ts)
areaList: string[] = ['A', 'B', 'C', 'D', 'L', 'T'];
errors = [
{ id: 'A7', clientName: 'fd', type: 'A' },
{ id: 'B1', clientName: 'sdfdfsu', type: 'B' },
{ id: 'E3', clientName: 'sdf', type: 'C' },
{ id: 'I2', clientName: 'fsdfu', type: 'D' },
{ id: 'L', clientName: 'sdfsf', type: 'L' },
{ id: 'L', clientName: 'sdfsf', type: 'T' }
];
【问题讨论】:
标签: angular typescript