0

Is it possible to validate a step before going to the next one and the linear mode is not enabled ?

When i disabled the linear mode of the stepper and set its property to false, i don't have the control to validate navigation between steps.

  • Please provide some code. – Igor Beaufils Nov 15 '22 at 10:12
  • By default the linear mode does exactly what it says : Basically, you need to validate your step to pass to the next one, by making it false you can pass any steps you want without validation. Please provide code, and precise your question – Igor Beaufils Nov 15 '22 at 10:18
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 15 '22 at 10:18

1 Answers1

0

No and yes.

Of course you can try to implement a hacky approach which basically mimics the exact same behavior of linear mode. By why should you do that? That's exactly what linear mode is for as mentioned in the docs (https://material.angular.io/components/stepper/overview#linear-stepper):

The linear attribute can be set on mat-stepper to create a linear stepper that requires the user to complete previous steps before proceeding to following steps.

So my suggestion is: If you want to perform some validation before navigation to the next step, just use linear mode instead of basically reimplementing it.

Update after feedback from comment

If you have specific stages where you don't need the linear step validation, you can just omit putting the stepControl directive or set [optional]="true" to it. (reference https://material.angular.io/components/stepper/overview#optional-step)

Fabian Strathaus
  • 3,192
  • 1
  • 4
  • 26
  • thank you for your response, But i want just to validate first step then allow users to go to last step without clicking to intermediate step, the linear mode will block this type of navigation. – chedi dridi Nov 15 '22 at 09:30