角度材料选择列表复选框未明显选中

时间:2020-06-08 20:54:56

标签: javascript angular angular-material

我有一个Angular Material 9选择列表绑定到数组,如他们的示例。

await NavigationService.NavigateAsync(""MyNamespace:///MenuPage/NavigationPage/ListPage");

<mat-selection-list #sendingList [(ngModel)]="selectedSendingFeatures"> <mat-list-option *ngFor="let item of sending" checkboxPosition="before" [value]="item"> {{ item }} </mat-list-option> </mat-selection-list> 是一个字符串数组,如其“鞋子”示例所示。

当我单击复选框时,模型会正确更新。但是复选框本身并未显示为选中状态。他们总是不受限制的。我在这里想念什么?

1 个答案:

答案 0 :(得分:0)

要将某个选项标记为选中的我们的selected属性

 <mat-selection-list #sendingList [(ngModel)]="selectedSendingFeatures">
      <mat-list-option *ngFor="let item of sending" checkboxPosition="before" selected>
        {{ item }}
      </mat-list-option>
 </mat-selection-list>

您可以进一步传递布尔值,以确保其遵循您的数据

[selected]="item.isSelected"
相关问题