I'm using a stepper with dynamic forms in each step. I have created methods for back and next button which I call on click of next and back button like this:
<button (click)="previousStage()" mat-raised-button matStepperPrevious>BACK</button>
<button mat-raised-button matStepperNext (click)="nextStage()">Next</button>
Now I also want to move backward and forward when user clicks on header navigation so I have created a method for that as well:
<mat-horizontal-stepper [linear]="true (selectionChange)="onNavChange($event)">
Inside the onNavChange(event) .. I call the method next or sub depending on the step name.
The problem is that when I click on next button then it is called twice... first it calls the onNavChange($event) and then the method called on next button.
How can I ensure that it is called only once? Is there a way that onNavChange() gets executed only when clicked on header?