0
votes

When user navigates from step 4 to step 2 in angular mat stepper I need to disable few buttons in step 2. I am trying to perform something like if selectedIndex = 1 and previous selected index is 3 disable buttons. But is there any way to check the previously selected index is 3 ?!

If(this.stepper.selectedIndex== 1 && previousSelectIndex == 3) 
{
   // disable buttons

}
1

1 Answers

0
votes

You can add a method for this purpose to get selectedIndex from stepper.

  @ViewChild('stepper')
      stepper: MatStepper;

    inClick(): void {
       let arrOfSelectedIndx = [];
       if(this.stepper.selectedIndex == 1 && this.stepper.selectedIndex == 3) {
          arrOfSelectedIndx.push(this.stepper.selectedIndex); 
         if(arrOfSelectedIndx.push.reduce((a, b) => a + b, 0) == 4)
         {
          // disable buttons

         }
       
     }
     else {
        arrOfSelectedIndx = []; 
      }

    }

Hope useful