How to switch between mat-vertical-stepper and mat-horizontal-stepper from angular component with same stepper steps?
There are three main types of stepper motors: Permanent magnet stepper. Variable reluctance stepper. Hybrid synchronous stepper.
Overview for stepper. Angular Material's stepper provides a wizard-like workflow by dividing content into logical steps. Material stepper builds on the foundation of the CDK stepper that is responsible for the logic that drives a stepped workflow. Material stepper extends the CDK stepper and has Material Design styling ...
There does not seem to be option to change color of mat stepper icon, you can use this css as workaround. Custom theme class can be used across application,just wrapp any material component and use color attribute primary,accent or warn as defined in class.
to avoid rewriting identical html content, do like this. Create the template and give them a reference using a #hashtag
. then you can instert them using ng-container *ngTemplateOutlet="hashtag"></ng-container>
.
here is an example of making a responsive stepepr, the angular material way.
<ng-template #stepOne> <div>step one</div> </ng-template> <ng-template #stepTwo> <div>step two</div> </ng-template> <ng-template #stepThree> <div>step three</div> </ng-template> <ng-template #stepFour> <div>step four</div> </ng-template> <ng-template [ngIf]="smallScreen" [ngIfElse]="bigScreen"> <mat-vertical-stepper linear #stepper > <mat-step> <ng-container *ngTemplateOutlet="stepOne"></ng-container> </mat-step> <mat-step> <ng-container *ngTemplateOutlet="stepTwo"></ng-container> </mat-step> <mat-step> <ng-container *ngTemplateOutlet="stepThree"></ng-container> </mat-step> <mat-step> <ng-container *ngTemplateOutlet="stepFour"></ng-container> </mat-step> </mat-vertical-stepper> </ng-template> <ng-template #bigScreen> <mat-horizontal-stepper linear #stepper > <mat-step> <ng-container *ngTemplateOutlet="stepOne"></ng-container> </mat-step> <mat-step > <ng-container *ngTemplateOutlet="stepTwo"></ng-container> </mat-step> <mat-step> <ng-container *ngTemplateOutlet="stepThree"></ng-container> </mat-step> <mat-step> <ng-container *ngTemplateOutlet="stepFour"></ng-container> </mat-step> </mat-horizontal-stepper> </ng-template>
You can use the angular cdk layout to track screen size like this.
import { Component } from '@angular/core'; import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; @Component({ selector: 'app-responsive-stepper', templateUrl: './responsive-stepper.component.html', styleUrls: ['./responsive-stepper.component.scss'] }) export class ResponsiveStepperComponent implements OnInit { smallScreen: boolean; constructor( private breakpointObserver: BreakpointObserver ) { breakpointObserver.observe([ Breakpoints.XSmall, Breakpoints.Small ]).subscribe(result => { this.smallScreen = result.matches; }); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With