Get 2024 Templates Mega Bundle!19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets
Get for 99$

How to use StepperComponent in Angular?


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>


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


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>";


Initialize the `StepperComponent` in your Angular component. You can use the `ngAfterViewInit` lifecycle hook to ensure the DOM elements are ready.


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);
}
}
}


Use the `app-stepper` component in your Angular template.


<app-stepper></app-stepper>


Add the necessary HTML structure and content within the `app-stepper` component's template.


<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>


Style the stepper component as per your design requirements and enhance its functionality using Angular features as needed.

Adjust the `StepperComponent` initialization code to fit your Angular project's structure and requirements.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(