1

I have a Stepper with 3 steps each has it's own component. I am not using Forms at each step so i have bunch of input fields at every step.

The problem is Oninit method of all steps are called at load of first step itself. This messes up my code as i load data from a variable passed from Ist step to 2nd step. Is there a way to avoid loading all oninit of every step on the first step itself?

See the problem on below link and open console: https://stackblitz.com/edit/angular-vpoj5j

I cannot find a solution though i found someone else also encountered the same. https://github.com/angular/material2/issues/7985

Neeraj
  • 1,163
  • 2
  • 18
  • 32
  • could u create only one form an put all steps in that? just a suggestion. – Akj Aug 30 '18 at 04:55
  • 1
    did you try active step with conditionally load step component. so it won't get initialized. – TheParam Aug 30 '18 at 05:15
  • @changulpaye - Can you provide an example ? I could not stop ngOnInit for all steps to be called as soon as the parent component is loaded. – Neeraj Aug 30 '18 at 14:14

1 Answers1

0

You can use the #stepper selectedIndex property to show the component and trigger the ngOnInit event.