3

I have a material-vertical-stepper in my application, which is shown inside a bootstrap modal. I have used (selectionChange) directive inside mat-vertical-stepper to track the onchange event. But it is not triggered initially. My stepper data is dynamic and steps are listed based on db values. I need to execute a function when the mat stepper is loaded and this need to be executed once. Any help please.

<mat-vertical-stepper [linear]="true" fxLayout="column" fxFlex="100" fxLayoutAlign="stretch" #stepper [selectedIndex]="selectedIndex" (selectionChange)="loadPattern($event)">
     <mat-step *ngFor="let template of TemplateArray; let i = index" fxFlex="100"  fxLayout="column">
          <ng-template matStepLabel>Pattern {{i + 1}}  </ng-template>
     </mat-step>
  </mat-vertical-stepper>
Yadu Chandran
  • 177
  • 13
  • I think what you want is to check if your data is loaded and then conditionnaly apply your stepper. I am not sure if I completely understand what you want but it is unrelated to the stepper itself. What do you expect the function to do when the mat stepper is displayed ? – edkeveked Aug 22 '19 at 07:25
  • Could you post the complete code? – LppEdd Aug 22 '19 at 07:27
  • Thanks for your response edkeveked. Data is loaded and is working. But how can i track if the stepper is loaded. Any event like (selectionChange) available for on load – Yadu Chandran Aug 22 '19 at 07:29
  • @LppEdd I have editted my question. Code is updated. – Yadu Chandran Aug 22 '19 at 07:33
  • @YaduChandran but I don't understand, what do you want to be notified about? The event you're looking for what data does it have to pass to you? – LppEdd Aug 22 '19 at 07:36
  • @LppEdd First step is always active in material stepper. I have included an ng-template inside each step dynamically. When user changes any step manually a function is triggered and an operation takes place. This works fine when the users changes the steps manually. But initially it wont work. I have made this mat-vertical-stepper inside a modal. ngAfterViewInit still showing undefined. – Yadu Chandran Aug 22 '19 at 13:09
  • @YaduChandran what is still `undefined`? – LppEdd Aug 22 '19 at 13:14
  • @LppEdd inside ngAfterViewInit MatStepper is undefined. My stepper is inside a modal. – Yadu Chandran Aug 23 '19 at 03:59
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/198346/discussion-between-yadu-chandran-and-lppedd). – Yadu Chandran Aug 23 '19 at 04:49
  • 2
    did you find the answer? – Adnan Nov 13 '19 at 08:33

0 Answers0