How do I use StepperComponent
from _StepperComponent.ts
file in Angular project.
I copied this from html documentation and tried to make use of it, but couldn't make it work, couldn't find docs with anything other than html.
<div class="stepper stepper-pills stepper-column d-flex flex-column flex-xl-row flex-row-fluid" id="kt_modal_create_app_stepper">
<div ... ></div>
</div>
Hi Luzan Baral
Sorry for the delay in response. To use the `StepperComponent` in an Angular project, you can follow these steps:
In your Angular component where you want to use the `StepperComponent`, import the plugin.
import { StepperComponent, defaultStepperOptions } from "<path-to-plugin>";
import { AfterViewInit, Component, ElementRef } from "@angular/core";
@Component({
selector: "app-stepper",
template: `
<div #stepperElement data-kt-stepper>
<!-- Your stepper content here -->
</div>
`,
})
export class StepperComponent implements AfterViewInit {
constructor(private elementRef: ElementRef) {}
ngAfterViewInit(): void {
const stepperElement = this.elementRef.nativeElement.querySelector("[data-kt-stepper]");
if (stepperElement) {
new StepperComponent(stepperElement, defaultStepperOptions);
}
}
}
<app-stepper></app-stepper>
<div #stepperElement data-kt-stepper>
<div data-kt-stepper-element="nav">Step 1</div>
<div data-kt-stepper-element="content">Content 1</div>
<div data-kt-stepper-element="nav">Step 2</div>
<div data-kt-stepper-element="content">Content 2</div>
<div data-kt-stepper-element="nav">Step 3</div>
<div data-kt-stepper-element="content">Content 3</div>
</div>