You can also do this by specifying the actual stepper index using selectedIndex.
stackblitz: https://stackblitz.com/edit/angular-4rvy2s?file=app%2Fstepper-overview-example.ts
HTML:
<div class="fab-nav-container">
<mat-vertical-stepper linear="false" #stepper>
<mat-step *ngFor="let step of stepNodes; let i = index">
<ng-template matStepLabel>
<p> {{step.title}} </p>
</ng-template>
</mat-step>
</mat-vertical-stepper>
</div>
<div class="button-container">
<div class="button-grp">
<button mat-stroked-button (click)="clickButton(1, stepper)">1</button>
<button mat-stroked-button (click)="clickButton(2, stepper)">2</button>
<button mat-stroked-button (click)="clickButton(3, stepper)">3</button>
</div>
</div>
TS:
import {Component, OnInit, ViewChild} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { MatVerticalStepper } from '@angular/material';
import { MatStepper } from '@angular/material';
export interface INodes {
title: string;
seq: number;
flowId: string;
}
@Component({
selector: 'stepper-overview-example',
templateUrl: 'stepper-overview-example.html',
styleUrls: ['stepper-overview-example.scss'],
})
export class StepperOverviewExample implements OnInit {
@ViewChild(MatVerticalStepper) vert_stepper: MatVerticalStepper;
@ViewChild('stepper') private myStepper: MatStepper;
stepNodes: INodes[] = [
{ title: 'Request Submission', seq: 1, flowId: 'xasd12'},
{ title: 'Department Approval', seq: 2, flowId: 'erda23'},
{ title: 'Requestor Confirmation', seq: 3, flowId: 'fsyq51'},
];
ngOnInit() {
}
ngAfterViewInit() {
this.vert_stepper._getIndicatorType = () => 'number';
}
clickButton(index: number, stepper: MatStepper) {
stepper.selectedIndex = index - 1;
}
}
source
share