Angular material stepper下一步显示create而不是1

Shi*_*rav 5 javascript angular-material angular

我正在使用步进器,我想禁用下一步,直到所有填充都应该填充,所以我在html文件中线性化为true

<mat-horizontal-stepper [linear]="true" #stepper>
        <mat-step [stepControl]="firstFormGroup">
          <form [formGroup]="firstFormGroup">
Run Code Online (Sandbox Code Playgroud)

它工作正常但每当我要进入下一步时,"1"在我检查时变成"cre"

在此输入图像描述

我没有用户在我的代码中创建它来自mat-icon

Fat*_*zli 19

你可以[completed]="false"开启mat-step,你将只有数字而不是图标.

或者"create"用钢笔图标替换单词,您需要添加谷歌材料字体图标链接:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons"rel="stylesheet">


Saa*_*mar 8

在 mat-h​​orizo​​ntal-stepper 中添加#stepper

<mat-horizontal-stepper [linear]="true" #stepper>
....
</mat-horizontal-stepper>
Run Code Online (Sandbox Code Playgroud)

然后在 .ts 文件中获取那个步进器

@ViewChild('stepper') stepper: MatHorizontalStepper;
Run Code Online (Sandbox Code Playgroud)

最后,在 afterViewInit 中执行

ngAfterViewInit() {
  this.stepper._getIndicatorType = () => 'number';
}
Run Code Online (Sandbox Code Playgroud)