как сделать активными предыдущие шаги шага selectedIndex, используя угловой материал stepper и angular 6 - PullRequest
0 голосов
/ 06 июля 2019

Я использую угловой шаговый материал, и мне нужно активировать все предыдущие шаги до шага selectedIndex в угловом 6. Я уже пробовал использовать линейный шагер, но получаю только активный шаг для selectedIndex не для всех предыдущих индексов. Пример у меня 5 шаги и я выбираю 3-й, я получаю только 3-й шаг в активном, оставаясь 1-й и 2-й шаги неактивны, мне нужно активировать 1-й, 2-й, 3-й шаги

угловой 6, угловой материал 6

в HTML

<div class="col-lg-7" *ngIf="!process">
                           <mat-horizontal-stepper [linear]="isLinear" 
 [selectedIndex]="currentStep" #stepper>
                             <ng-container *ngFor="let step of steps">
                                   <ng-template matStepperIcon="home">
                                       <mat-icon>home</mat-icon>
                                     </ng-template>
                               <mat-step  [editable]="isEditable">
                                 <ng-template matStepLabel>{{step}}</ng- 
    template>
                               </mat-step>
                             </ng-container>
                           </mat-horizontal-stepper>
                         </div>  

в тс

```
isLinear = true;
      process: Boolean;
      steps = [ "Ordered", "Packed", "Shipped", 'Transit', "Delivered" ];
      this.process = true;
        setTimeout(() => {
          this.currentStep = 2;
          this.process = false;
        }, 1500);

I expected first three steps are active mode but i got only 3rd step in active mode

1 Ответ

0 голосов
/ 09 июля 2019

Вы можете пометить шаги перед выбранным шагом как завершенные:

<mat-horizontal-stepper [linear]="isLinear" [selectedIndex]="currentStep" #stepper>
    <ng-container *ngFor="let step of steps; index as i">
        <ng-template matStepperIcon="home">
            <mat-icon>home</mat-icon>
        </ng-template>
        <mat-step #matStep [editable]="isEditable" 
                [completed]="matStep.interacted || i < currentStep">
            <ng-template matStepLabel>{{step}}</ng-template>
        </mat-step>
    </ng-container>
</mat-horizontal-stepper>
...