<mat-selection-list [(ngModel)]="selectedContactTypes" [ngModelOptions]="{standalone: true}">
<mat-list-option *ngFor="let ct of contacttypes" [checkboxPosition]="before" [value]="ct.id+'_'+ct.description">
<mat-icon matListIcon>perm_contact_calendar</mat-icon>
{{ct.description}}
</mat-list-option>
</mat-selection-list>
答案 0 :(得分:1)
在这种情况下,将它们包裹在div
上可以完成任务:
<mat-selection-list [(ngModel)]="selectedContactTypes" [ngModelOptions]="{standalone: true}">
<mat-list-option *ngFor="let ct of contacttypes" [checkboxPosition]="before" [value]="ct.id+'_'+ct.description">
<div>
<mat-icon matListIcon>perm_contact_calendar</mat-icon>
{{ct.description}}
</div>
</mat-list-option>
</mat-selection-list>
<强>更新强>
并且,如果您想要垂直居中,请将display: flex
和align-items: center
应用于div
<mat-selection-list [(ngModel)]="selectedContactTypes" [ngModelOptions]="{standalone: true}">
<mat-list-option *ngFor="let ct of contacttypes" [checkboxPosition]="before" [value]="ct.id+'_'+ct.description">
<div class="center-vertically">
<mat-icon matListIcon>perm_contact_calendar</mat-icon>
{{ct.description}}
</div>
</mat-list-option>
</mat-selection-list>
CSS:
.center-vertically{
display:flex;
align-items: center;
}