我一直在查看 material.angular.io/components/list/overview 的 material.angular.io 文档中的 mat-selection-list
我想使用对象数组而不是字符串数组。文档有
typesOfShoes: string[] = ['Falta passar fio', 'Peça oxidada'];
这似乎可行,但我在下面的对象不起作用。我做错了什么?或者这是不可能的?
errorList = [
{ id: 1234, type: 'A1', description: 'dsfdsfdfgdgdgfio', selected:false },
{ id: 4567, type: 'C6', description: 'Pesdffsdça sdfsd', selected:false },
{ id: 7890, type: 'A5', description: 'sdfdsfc', selected:false }
];
<mat-selection-list #errorList class="area-block ">
<mat-list-option *ngFor="let err of errorList " style="color: #000000;">
{{err.type}}
</mat-list-option>
</mat-selection-list>
<p style="color: #000000;" class="area-block">
Options selected: {{errorList.selectedOptions.selected.length}}
</p>