如何为mat-radio-button或mat-radio-group设置占位符?

时间:2019-11-09 18:56:38

标签: angular angular7 angular8

我有一个DOM元素:

<mat-radio-group [formControlName]="field.name" [disabled]="field?.disabled">
  <div>
    <mat-label>{{ placeholder }}</mat-label>
  </div>
  <mat-radio-button *ngFor="let option of field.options" [value]="option.value">
    {{ option.label }}
  </mat-radio-button>
</mat-radio-group>

如何为mat-radio-buttonmat-radio-group设置本地占位符?

1 个答案:

答案 0 :(得分:1)

这可能会帮助:

<fieldset>
    <legend>
        <label [attr.for]="aaa">PlaceHolder</label>
    </legend>
    <div class="row">
        <mat-radio-group aria-label="Select an option">
            <mat-radio-button value="1">Option 1</mat-radio-button>
            <mat-radio-button value="2">Option 2</mat-radio-button>
        </mat-radio-group>
    </div>
</fieldset>

外观:

enter image description here