【问题标题】:How to find previous selected index of angular mat stepper如何找到以前选择的角度垫步进器索引
【发布时间】:2021-01-16 07:32:06
【问题描述】:

当用户在角度垫步进器中从第 4 步导航到第 2 步时,我需要在第 2 步中禁用几个按钮。我正在尝试执行类似于 selectedIndex = 1 且先前选择的索引为 3 个禁用按钮的操作。但是有什么方法可以检查之前选择的索引是 3 吗?!

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

}

【问题讨论】:

    标签: angular angular-material mat-stepper


    【解决方案1】:

    您可以为此添加一个方法来从步进器中获取 selectedIndex。

      @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 = []; 
          }
    
        }
    

    希望有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 2016-12-27
      • 2017-06-03
      • 2021-10-21
      • 2020-10-06
      • 1970-01-01
      • 2019-05-27
      相关资源
      最近更新 更多