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