I am using a component-based mat stepper component to display a linear process. Each step have own component as below
<mat-card>
<mat-horizontal-stepper [linear]="isLinear" labelPosition="bottom" #stepper>
<!-- Step-1 -->
<mat-step [stepControl]="firstFormGroup">
<ng-template matStepLabel>Select Items</ng-template>
<select-item-component>
<select-item-component>
<div class="mt-5">
<button mat-flat-button color="primary" matStepperNext>Next</button>
</div>
</mat-step>
<!-- Step-2 -->
<mat-step [stepControl]="firstFormGroup">
<ng-template matStepLabel>Add Quantity</ng-template>
<add-qty-component>
<add-qty-component>
<div class="mt-5">
<button mat-flat-button color="primary" matStepperNext>Next</button>
</div>
</mat-step>
<!-- Step-3 -->
<mat-step [stepControl]="firstFormGroup">
<ng-template matStepLabel>Conform</ng-template>
<conform-step-component>
<conform-step-component>
<div class="mt-5">
<button mat-flat-button color="primary" matStepperNext>Done</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-card>
Step-1 shows the multi selectable list of items and pass selected item list to the next step-2 and add a quantity of each item in step-2.
How to pass selected items on Next click from step-1 to step-2 and display passed item to enter a quantity in step-2?
I have created a common service layer to set and get selected items. ngOnInit
of a component of step-2 trying to get the selected list from common service but issue is component-2 is already initiated before the next click.
Can do initialize or re-initialize the second component after the click of next in step-1?
How to display the selected items list in step-2 after moving from step-1?
What will be the best approach for the above scenario?
Just a link to any reference that can answer my question, it should be enough.
Thank you.