将步骤编号更改为 Angular Material Stepper 中的垫子图标

Dev*_*emi 1 angular-material angular

我想创建一个 Angular Material stepper,但我想使用 mat-icons 而不是气泡内的数字,我应该怎么做?

小智 6

您可以使用matStepperIcon覆盖图标。

<mat-horizontal-stepper>
  <mat-step label="Step 1" state="minus">
    <p>Minus</p>
    <div>
      <button mat-button matStepperNext>Next</button>
    </div>
  </mat-step>
  <mat-step label="Step 2" state="plus">
    <p>Plus</p>
    <div>
      <button mat-button matStepperNext>Next</button>
    </div>
  </mat-step>

  <ng-template matStepperIcon="minus">
    <mat-icon>remove</mat-icon>
  </ng-template>
  <ng-template matStepperIcon="plus">
    <mat-icon>add</mat-icon>
  </ng-template>
</mat-horizontal-stepper>
Run Code Online (Sandbox Code Playgroud)

添加到组件:

providers: [{
  provide: STEPPER_GLOBAL_OPTIONS, useValue: {displayDefaultIndicatorType: false}
}]
Run Code Online (Sandbox Code Playgroud)