angular - Angular Material Stepper 组件的 StepState 是什么
问题描述
我正在尝试自定义step-numbers
类似1
, 2
,为每个步骤显示的步进器3
中的不同图标initial state
我目前step-numbers
可以通过使用下面的状态matStepperIcon
值来替换edit
ng-template
有了这个,我看到只有当我们进入下一步时,前面的步骤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
值的图标而不是 edit 。所以看到 donut_large 图标也显示在 Steppersreset
状态的步骤上。2)StepState
可以使用所有其他值,因为当我尝试使用任何其他值时,例如done
or reset
,matStepperIcon
它不起作用。它仅在我将值用作edit
. 根据角度材料网站上的文档,matStepperIcon
请参阅
@Input('matStepperIcon') |
name: StepState | Name of the icon to be overridden.
解决方案
这是 Angular Material(更准确地说是 CDK)中的 StepState(来自源代码):
/** 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>
推荐阅读
- javascript - 如何使用 useFocusEffect 挂钩来获取数据?
- android - JSON 中的多种数据类型
- kubernetes - Kubernetes 连接服务和部署
- php - 在 Laravel 中注册时无法向用户发送电子邮件
- android - 即使在 .xml 文件中添加 tools:showIn="navigation_view" 后,我也无法获得导航抽屉的预览
- javascript - 尝试调用函数并在 post 方法中返回数据
- node.js - 如何在 monorepo 中共享类实例?
- bash - 逐行读取并将每一行分配给 Bash 中的不同变量
- c# - 尝试使用 codegenerator 在 aspnet core 3 中生成控制器时出错
- php - 一旦页面插入数据并重定向到旧页面,如何获取查询字符串值