Change step number to a mat-icon in an Angular Material Stepper

假如想象 提交于 2020-02-03 02:11:54

问题


I want to create an Angular Material stepper, but instead of a number inside the bubble I want to use mat-icons, how should I do this?


回答1:


You can use matStepperIcon to override the icon.

<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>

Add to the component:

providers: [{
  provide: STEPPER_GLOBAL_OPTIONS, useValue: {displayDefaultIndicatorType: false}
}]


来源:https://stackoverflow.com/questions/54383116/change-step-number-to-a-mat-icon-in-an-angular-material-stepper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!