我正在使用 angular-material select 创建一个下拉菜单,我在其中提供了选择多个值的选项。
<accordion [showArrows]="true" class="programstyle">
<accordion-group heading="EVENTS" [isOpened]="true">
<div class="">
<mat-form-field class="width100">
<mat-select class="width100" placeholder="Events" [(ngModel)]="studentInput.programType" (change)="filter()" id="programTypeValueId" name="programTypeValueId">
<mat-option disabled>Select Events</mat-option>
<mat-option *ngFor="let program of programs" [value]="program.campusEventId">{{program.eventName}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</accordion-group>
<accordion-group heading="SKILLS">
<div class="">
<mat-form-field class="width100">
<mat-select multiple class="width100" placeholder="Select Skills" [(ngModel)]="studentInput.skills" (change)="filter()" id="skillTypeValueId" name="skillTypeValueId">
<mat-option disabled>Select Skills</mat-option>
<mat-option *ngFor="let skill of skills" [value]="skill.lookupValueId">{{skill.lookupValue}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</accordion-group>
<accordion-group heading="INTERESTS">
<div class="">
<mat-form-field class="width100">
<mat-option>Select Interests</mat-option>
<mat-select multiple class="width100" placeholder="Select Interests" [(ngModel)]="studentInput.interest" (change)="filter()" id="interestTypeValueId"
name="interestTypeValueId">
<mat-option *ngFor="let interest of interests" [value]="interest.lookupValueId">{{interest.lookupValue}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</accordion-group>
</accordion>
这是 HTML 部分。
为了将选项定义为选择事件,我使用了选择事件。但是我在启用复选框的情况下得到了这个。我不希望下拉列表中的第一个选项启用复选框。有什么办法可以让我有没有复选框的第一个选项?
最佳答案
每个 mat-option
都有一个 mat-pseudo-checkbox
来处理复选框样式(我从 chrome 开发工具中检查了它)。试试这个( Angular 5, Material 2):
::ng-deep .mat-option:first-child .mat-pseudo-checkbox{ display: none; }
关于javascript - 在多选的情况下隐藏 Angular 垫选择的复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49253101/