I want to navigate the stepper only through the next and back buttons.
I can\'t get this to work since users can also click each step label to navigate to any step. I c
Don't use ::ng-deep as it is deprecated.
https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep
Instead, if you are using Angular Material, use the theme guide from the documentation.
https://material.angular.io/guide/theming
Example of a implementation of the style:
my-custom-elements.scss
@import '~@angular/material/theming';
@mixin custom-stepper-theme() {
.mat-horizontal-stepper-header {
pointer-events: none;
}
}
global-material-theme.scss
@import '~@angular/material/theming';
// Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();
@import './material/my-custom-elements.scss';
@include custom-stepper-theme();
angular.json
...
"styles": ["src/styles.scss", "src/app/global-material-theme.scss"]
...
Here ::ng-deep .mat-horizontal-stepper-header-container {
display: none ;
}
Use this on your style sheet to remove stepper header...Like Step-1,Step-2
I found a somewhat hacky solution for this. The problem is that you cannot fully disable the header navigation, but you can prevent it from being active until a certain moment.
And that moment is form.invalid
.
My situation was the following: User needs to fill the form inside the step, press 'save' and only then be able to use NEXT
button and navigate the stepper further (also back).
What I did was introduce another hidden
input
which would be using angular's [required]
dynamic attribute. It will only be required
if the previous save
condition wasn't successful. Once it succeeds this field won't be required
and user can navigate further.
Together with mat-stepper (or md-stepper) attribute editable
you should be able to achieve what you want.
Let me know if you fully understood the idea.
You need to add an "linear" attribute (This will disable navigation)
<mat-vertical-stepper linear>
Does not work without ::ng-deep
::ng-deep .mat-horizontal-stepper-header{
pointer-events: none !important;
}
Add this to your style sheet. I was trying to disable the header navigation. Tried many things but this hack worked. You can try this till Angular Material Team support this feature.
::ng-deep .mat-horizontal-stepper-header{
pointer-events: none !important;
}