javascript - 在多选的情况下隐藏 Angular 垫选择的复选框?

标签 javascript html css angular angular-material

我正在使用 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 部分。
为了将选项定义为选择事件,我使用了选择事件。但是我在启用复选框的情况下得到了这个。我不希望下拉列表中的第一个选项启用复选框。有什么办法可以让我有没有复选框的第一个选项?

enter image description here

最佳答案

每个 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/

相关文章:

css - z-index 断章取义

javascript - 具有平滑滚动的顶部 anchor ,不会重复

javascript - 如何将两个数组的值获取到同一个html javascript

javascript - 在点击事件中取消绑定(bind)preventDefault?

javascript - 删除当前上传项目的一个 div

html - Safari 视口(viewport)错误,固定位置和底部或顶部的问题

javascript - 当离开视口(viewport)时,Flash Player 停止动画

javascript - 在服务器端还是客户端进行图像处理?

html - 下拉菜单(Superfish)在 IE 中有效,在 FF/Chrome 中损坏?

html - HTML/CSS 中的下拉菜单实际上不是 "drop down"