步进状态不适用于动态步进器

时间:2020-06-24 03:33:20

标签: angular mat-stepper

我正在尝试动态创建角度步进器。 (角度9)

forms是FormGroup的数组 状态是状态数组 最初

states = ['number', 'number'];

并更改状态,例如

 states = ['error', 'done'];

如果表单无效,则更改为“错误”;如果有效,则更改为“完成”

<mat-horizontal-stepper *ngIf="forms && forms.length > 0">
    <mat-step *ngFor="let form of forms; let i = index"
              [label]="step.label"
              [stepControl]="form"
              [state]="states[i]">
        <form [formGroup]="form">
        // some code
        </form>
    </mat-step>
</mat-horizontal-stepper>

但是状态图标仍然是默认图标,灰色表示无效,而编辑图标表示有效。 我加了

<ng-template matStepperIcon="done">
        <mat-icon>done</mat-icon>
</ng-template>
<ng-template matStepperIcon="error">
        <mat-icon>warning</mat-icon>
</ng-template>

,但是它不起作用。 如何更改动态步进器的状态图标?

0 个答案:

没有答案