有没有办法隐藏 Angular 中的 mat-radio-button 并使其内部的图像可点击?

Sar*_*raJ 2 html sass angular material-table

这就是到目前为止的样子,我试图隐藏单选按钮并使用男性和女性的图像。这是 mat-radio-group 的 html 代码:

   <mat-radio-group formControlName="gender">
            <mat-label>
              <mat-radio-button class="female-radio" value="M"></mat-radio-button>
              <img width="100" src={{imageTwo}}>
              </mat-label>
              <mat-label>
                <mat-radio-button class="female-radio" value="F"></mat-radio-button>
                <img width="100" src={{imageOne}}>
              </mat-label>
          </mat-radio-group>
Run Code Online (Sandbox Code Playgroud)

在我的 scss 组件中我做了:

.female-radio + img {
  cursor: pointer;
}

.mat-radio-checked + img {
  outline: 2px solid #f00;
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能只显示图像来选择性别?

Nit*_*ish 5

请在您的组件 html 中进行以下更改

<mat-radio-group formControlName="gender">
  <mat-label>
    <mat-radio-button class="female-radio" value="M">
      <img width="100" src={{imageTwo}}>
    </mat-radio-button>
    </mat-label>
    <mat-label>
      <mat-radio-button class="female-radio" value="F">
        <img width="100" src={{imageOne}}>
      </mat-radio-button>
    </mat-label>
</mat-radio-group>
Run Code Online (Sandbox Code Playgroud)

并将以下 css 添加到 css/scss 文件中

:host ::ng-deep .mat-radio-container {
  display: none;
}

Run Code Online (Sandbox Code Playgroud)

这将仅显示图像,功能将保持原样。所选项目的值仍然可以在 formControlName 中访问gender