angular material stepper: disable header navigation

后端 未结 11 1004
再見小時候
再見小時候 2021-02-03 18:16

I want to navigate the stepper only through the next and back buttons.

I can\'t get this to work since users can also click each step label to navigate to any step. I c

11条回答
  •  终归单人心
    2021-02-03 19:15

    For anyone that's still looking for an alternate solution if ::ng-deep does not work.

    Furthermore, ::ng-deep is deprecated and setting ViewEncapsulation to none is the preferred way to go if you want to do it using CSS.

    Import ViewEncapsulation and set to None in your

    compnent.ts:

    import { Component, OnInit, ViewEncapsulation } from "@angular/core";
    
    @Component({
      selector: "stepper-overview-example",
      templateUrl: "stepper-overview-example.html",
      styleUrls: ["stepper-overview-example.css"],
      encapsulation: ViewEncapsulation.None
    })
    export class StepperOverviewExample implements OnInit {
      isLinear = false;
    
      constructor() {}
    
      ngOnInit() {}
    }
    

    set pointer-events to none in your

    component.css:

    .mat-horizontal-stepper-header { 
      pointer-events: none !important; 
    }
    

    Here's a DEMO.

提交回复
热议问题