Within the Angular 8 Material Stepper I'm checking some form state and if it passes, then I set stepCompleted to true.
Here's a Stackblitz that demos this: https://stackblitz.com/edit/angular-mat-stepper-demo-with-fields?file=src%2Fapp%2Fapp.component.html
The problem is that Angular does not pick up on the change right away, therefore we have to click next twice. On the second click it will see the state change.
Also if we navigate back to the step and change the parameters such that the step should not proceed, Angular will still allow the step to proceed on first click, because it still sees stepCompleted as being true. It's not false until we navigate back again.
I think the right way to fix this is to inject ChangeDetectorRef and call it like this:
stepComplete() {
//See whether the step is complete
//if so
this.stepCompleted = true;
this.cd.detectChanges();
}
Thoughts?
stepCompleteto true, but only if a certain condition is met. However Angular does realize thatstepCompletehas been set to true on the first click. It realizes it on the second click. - Ole