How to change state icon in Angular material stepper dynamically created component?

A.A

I am using Angular material stepper component in the following example stackblitz

and I am trying to change dynamically the default numbers of each step to material icons by changing the state of selector mat-step using table stepicons in ngoninit. Can anyone help me with this?

<mat-vertical-stepper (selectionChange)="selectionChanged($event)" [linear]="true" style="width:100%;height:100%">
<ng-template matStepperIcon="edit">
    <mat-icon>done</mat-icon>
</ng-template>
<ng-template matStepperIcon="category">
    <mat-icon>category</mat-icon>
</ng-template>
<ng-template matStepperIcon="apps">
    <mat-icon>apps</mat-icon>
</ng-template>
<ng-template matStepperIcon="search">
    <mat-icon>search</mat-icon>
</ng-template>
<mat-step *ngFor="let step of steps; let i = index" [label]="step.title" state="stepicons.text">

    <router-outlet *ngIf="i === selectedStepIndex"></router-outlet>

    <button mat-raised-button color="primary" matStepperNext
    style="margin-top:10px; float: left;position: relative;">Επόμενο</button>
</mat-step>

Indrakumara

Hope you are looking similar answer

https://stackblitz.com/edit/pxblue-dynamic-stepper-angular-n7bnmh

Add div and loop your steps array instead of mat-step loop

 <div *ngFor="let step of steps; let i = index">
<mat-step  [completed]="step.completed" [state]=myState[i]>
  <form>
    <ng-template matStepLabel>{{step.title || 'Choose an action'}}
      <mat-icon class="delete_icon"  *ngIf="stepper.selectedIndex === i" (click)="removeStep(i)"
        matTooltip="Remove step" matTooltipPosition="right">delete</mat-icon>
    </ng-template>
    <mat-radio-group class="radio-group" (change)="changeStepSelection($event, i)">
      <mat-radio-button style=" margin: 10px 0 " *ngFor="let option of stepOptions" [value]="option.value">
        {{option.label}}
      </mat-radio-button>
    </mat-radio-group>
  </form>
</mat-step>
</div>

put it into array your icon template text to get the relevant icon (you can build own your logic here)

myState = ['category','apps','search'];

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular 2 Header component Title change dynamically according to the state

is there an option to change icon for completed step in material-2 stepper

Style dynamically created Angular component

Angular Material Stepper Component For Each Step

How to change angular material stepper step numbers to any icon or text?

How to target angular material stepper padding with CSS?

How to change angular material sort icon

Override the default icon from mat-stepper angular material

How to change color of angular material stepper step icons

How to set material stepper to open second item by default and set the icon color?(Angular Material)

How to submit forms in Stepper in Angular 4 material?

How to dynamically change the number of steps in stepper in flutter?

Angular material stepper change icon color

How to change the angular material mat stepper label color?

How to load steps dynamically using Angular material stepper

How to customize Angular Material stepper component showing label at the top?

How to change state icon in Angular Material stepper?

Angular Material: How to set each mat-horizontal-stepper stepper icon with different background color in TS

Angular Material Stepper - how to dynamically create components to load into steps

How to destroy component created dynamically angular 8

Change state from dynamically created child component - React

Angular 9 - Remove default icon (create) on Angular Material Stepper

How to add tooltip to Angular material stepper

wrong icon in material angular stepper

Using the ChangeDetectorRef to detect component state changes in order to step with the material stepper?

Angular how to change a 2 state component to a multi-state component

How to make CSS change in Angular Material Stepper?

How to change icon in angular component

Angular Material Stepper with reusable form component