【问题标题】:Angular material stepper next step showing create instead of 1Angular 材料步进器下一步显示创建而不是 1
【发布时间】:2018-07-06 16:17:16
【问题描述】:

我正在使用步进器,我想禁用下一步,直到所有填充都被填充,所以我将线性设置为 true html文件

<mat-horizontal-stepper [linear]="true" #stepper>
        <mat-step [stepControl]="firstFormGroup">
          <form [formGroup]="firstFormGroup">

它工作正常,但每当我进入下一步时,“1”变成“cre” 在检查我得到了

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

【问题讨论】:

  • 尝试在 mat-step 上设置 [completed]="false" 以仅获取数字。
  • 只需查看整个垫子步进器垫子步骤,然后将其固定。它可能与错误的封闭标签有关。

标签: javascript angular angular-material


【解决方案1】:

您可以在mat-step 上设置[completed]="false",您将只有数字而不是图标。

或者将"create"这个词替换为你需要添加google材料字体图标链接的钢笔图标:

&lt;link href="https://fonts.googleapis.com/icon?family=Material+Icons"rel="stylesheet"&gt;

【讨论】:

  • @ShivGaurav 你的欢迎 shiv.material 应该添加一个属性来显示数字而不仅仅是图标。
  • [completed]="false" 不允许导航到下一步:(
  • 使用 [completed]="false" 是不正确的。来自 Angular 文档:“将完成的属性传递给每个步骤,在它变为真之前不允许用户继续。”
  • google material font icon 链接对我有用,谢谢
【解决方案2】:

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

<mat-horizontal-stepper [linear]="true" #stepper>
....
</mat-horizontal-stepper>

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

@ViewChild('stepper') stepper: MatHorizontalStepper;

最后,在 afterViewInit 中进行

ngAfterViewInit() {
  this.stepper._getIndicatorType = () => 'number';
}

【讨论】:

  • 它应该只是@ViewChild('stepper') stepper: MatHorizontalStepper;,它就像一个魅力。
  • 来自另一个帖子 (stackoverflow.com/questions/60876479/…):我这样做了(更多类型完成):this.stepper._getIndicatorType = (): string =&gt; STEP_STATE.NUMBER;
【解决方案3】:

可能您使用另一个字体系列代替默认值。 您可以通过修复使用步进器的页面中字体系列的“材料图标”来解决此问题。

:host /deep/ .material-icons {
  font-family: 'Material Icons' !important;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-13
    • 2016-01-25
    • 1970-01-01
    • 2020-04-19
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多