Stepper: components inside step-content always get initialized
See original GitHub issueBug, feature request, or proposal:
Bug report
What is the expected behavior?
Initialize components when step is activated
What is the current behavior?
All components get initialized upon page load
What are the steps to reproduce?
Given template:
<mat-horizontal-stepper linear>
<mat-step label="First">
<my-first></my-first>
</mat-step>
<mat-step label="Second">
<my-second></my-second>
</mat-step>
</mat-horizontal-stepper>
Both components have a console.log() inside the constructor and ngAfterViewInit to check when they get called - they always get called upon page load.
I also tried with ng-containers around the components, “guarded” by ng-ifs - same problem!
<mat-horizontal-stepper linear>
<mat-step label="First">
<ng-container *ngIf="isActiveStep('First')">
<my-first></my-first>
</ng-container>
</mat-step>
<mat-step label="Second">
<ng-container *ngIf="isActiveStep('Second')">
<my-second></my-second>
</ng-container>
</mat-step>
</mat-horizontal-stepper>
What is the use-case or motivation for changing an existing behavior?
Instantiate the components when the step is active / re-instantiate when an already visited step is re-visited. This way the components could do some magic upon instantiation - and only then, when the step is currently active.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest of all (all RCs / GIT builds from today)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Keep the pervious step open Vertical Stepper Material-UI
Trying to implement a vertical stepper and keep the previous step open when I move the next one. I tried to use expanded...
Read more >Stepper | Angular Material
Stream that emits whenever the labels here are changed. Use this to notify components if the labels have changed after initialization. completedLabel: string....
Read more >React & Material UI #29: Stepper - YouTube
In this video we go over- What is a Material UI Stepper ? ... types of MUI Steppers - The props and sub...
Read more >React Stepper component - Material UI
Steppers convey progress through numbered steps. It provides a wizard-like workflow. Steppers display progress through a sequence of logical and numbered steps.
Read more >Mashy Teaches WebApp/Website Development with ...
It was only 2 days ago when I requested you to always start a new thread for your ... Each step content in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How did you fix the issue?
Try adding one more <ng-container> wrapper with *ngIf that checks current index.