![](/img/trans.png)
[英]Angular Material Stepper component showing label at the bottom
[英]What are the StepState of an Angular Material Stepper Component
我試圖自定義step-numbers
等1
, 2
, 3
示出了用於在具有不同的圖標的每個步驟initial state
步進的
我現在能夠通過在ng-template
使用edit
狀態的matStepperIcon
值替換step-numbers
,如下所示
有了這個,我看到只有當我們進入下一步時,前一步驟step-number
才會更改為icon
( donut_large
)。
<mat-vertical-stepper [linear]="isLinear" #stepper>
<ng-template matStepperIcon="edit"><mat-icon>donut_large</mat-icon> </ng-template>
<mat-step >
...為簡潔而排除的代碼......
1)我是否需要將donut_large
圖標與除編輯之外的其他matStepperIcon
值一起使用。 所以看到donut_large圖標也顯示在Steppers reset
狀態的步驟中。 2)可以使用所有其他StepState
值,因為當我嘗試使用matStepperIcon
任何其他值(如done
或reset
,它不起作用。 它僅在我將值用作edit
時才有效。 根據角度材料網站matStepperIcon
引用的文檔
@Input('matStepperIcon') | name: StepState | Name of the icon to be overridden.
以下是Angular Material中的StepState(更准確地說是CDK中的)(來自源代碼 ):
/** The state of each step. */
export type StepState = 'number' | 'edit' | 'done' | 'error' | string;
/** Enum to represent the different states of the steps. */
export const STEP_STATE = {
NUMBER: 'number',
EDIT: 'edit',
DONE: 'done',
ERROR: 'error'
};
這是一個示例代碼:
<mat-vertical-stepper #stepper>
<ng-template matStepperIcon="edit">
<mat-icon>fingerprint</mat-icon>
</ng-template>
<ng-template matStepperIcon="done">
<mat-icon>done</mat-icon>
</ng-template>
<ng-template matStepperIcon="number">
<mat-icon>code</mat-icon>
</ng-template>
<ng-template matStepperIcon="error">
<mat-icon>highlight_off</mat-icon>
</ng-template>
<mat-step>
<ng-template matStepLabel>Step 1 label</ng-template>
<p>Step 1</p>
</mat-step>
<mat-step>
<ng-template matStepLabel>Step 2 label</ng-template>
<p>Step 2</p>
</mat-step>
<mat-step>
<ng-template matStepLabel>Step 3 label</ng-template>
Step 3
</mat-step>
</mat-vertical-stepper>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.