【问题标题】:How to hide mat-stepper header in my mat-stepper?如何在我的垫子步进器中隐藏垫子步进器标题?
【发布时间】:2020-01-16 16:52:01
【问题描述】:

我正在使用 Angular-7 开发应用程序。在应用程序中,我使用了 Angular 材料的mat stepper。问题是,我如何隐藏mat-stepper 标头,如下图所示。我根本不希望它出现。

<mat-horizontal-stepper>
    <mat-step label="transaction">
        <button mat-button matStepperNext>Next</button>
    </mat-step>
    <mat-step label="personal">
        <button mat-button matStepperPrevious>Previous</button>
        <button mat-button matStepperNext>Next</button>
    </mat-step>
</mat-horizontal-stepper>

【问题讨论】:

标签: angular angular-material


【解决方案1】:

使用ngIf 来实现这一点。如果您想隐藏特定的mat-step,请将ngIf 放在mat-step 上。

<mat-step label="transaction" *ngIf="showStep">
    <button mat-button matStepperNext>Next</button>
</mat-step>

如果你想去掉整个mat-horizontal-stepper,那么把ngIf放在&lt;mat-horizontal-stepper&gt;

<mat-horizontal-stepper *ngIf="showStepper">

您可以将showStepshowStepper 的值更新为truefalse,具体取决于您是否要显示步进器。

注意:这也会删除内容。

如果您只想删除 mat-horizontal-stepper 标头并保留内容,则可以使用 CSS 来实现。

.mat-horizontal-stepper-header-container {
    display: none !important;
}

【讨论】:

  • 当我按照您的建议添加 时,所有按钮(上一个和下一个)都不再显示。我只想隐藏标签和图标。你能用我的代码给我看一个示例吗?
  • @ nash11 - 我在哪里添加 .mat-h​​orizo​​ntal-stepper-header-container { display: none !important; }
  • 将其添加到组件的样式中。如果您的组件使用 css 文件作为样式,则将其放入该文件中。
  • 要隐藏标题,在您的组件样式中使用::host ::ng-deep .mat-horizontal-stepper-header-container { display: none; }
猜你喜欢
  • 2018-07-09
  • 1970-01-01
  • 2020-11-28
  • 1970-01-01
  • 2021-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-27
相关资源
最近更新 更多