Search code examples
angularangular-materialstepper

Change numbering into double stepper with angular


I tried to print stepper into stepper:

<mat-vertical-stepper>
        <mat-step *ngFor="let step of Steps" [label]="step.name">
          <mat-vertical-stepper>
            <mat-step *ngFor="let substep of step.subnames" [label]="substep.subname">
            </mat-step>
          </mat-vertical-stepper>
          </mat-step>
    </mat-vertical-stepper>

It works but I would like to change numerotation:

change

  • 1
    • 1
    • 2
  • 2
    • 1
    • 2

into

  • 1
    • 1.1
    • 1.2
  • 2
    • 2.1
    • 2.2

How to do this, please?


Solution

  • Try something like this:

    EXAMPLE DEMO

    style.css:

    .mat-vertical-stepper-header .mat-step-icon, .mat-vertical-stepper-header .mat-step-icon-not-touched {
      font-size: 0px;
        margin-left: 10px;
        background-color: black;
        height: 5px;
        width: 5px;
    }
    .mat-vertical-stepper-header .mat-step-icon, .mat-vertical-stepper-header .mat-step-icon-touched {
      font-size: 0px;
        margin-left: 10px;
        background-color: black;
        height: 5px;
        width: 5px;
    }
    
    mat-step-header[ng-reflect-selected="true"] .mat-step-icon{ 
      font-size: 12px;
      align-self: center;
      color: white;
      height: 20px;
      width: 20px;
    }
    mat-step-header[ng-reflect-selected="false"] .mat-step-icon .mat-icon{ 
     display: none
    }
    

    HTML:

    <mat-vertical-stepper>
        <mat-step *ngFor="let step of Steps; let i= index;" [label]="step.name">
            <mat-vertical-stepper>
                <mat-step *ngFor="let substep of step.subnames; let j = index" label="{{i+1}}.{{j+1}}">
                </mat-step>
            </mat-vertical-stepper>
        </mat-step>
    </mat-vertical-stepper>