angular stepper change wait before changing code example

Example 1: angular stepper change wait before changing

// I personally do this in ngAfterViewInit() method
setTimeout(() => {
    this.stepper.steps.forEach((step, idx) => {
        step.select = () => {
            // Your custom code here
            // if you want to change step do execute code below
            this.selectedStepIndex = idx;
        };
    });
});

Example 2: angular stepper change wait before changing

@ViewChild('stepper', { static: false }) stepper: MatStepper;

Example 3: angular stepper change wait before changing

<mat-horizontal-stepper [selectedIndex]="selectedStepIndex" #stepper>