Open In App

Angular PrimeNG Steps Properties

Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will learn how to use the Steps Properties in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.

The Step component is used to indicate or track the completion of a series of processes.

Angular PrimeNG Steps Properties:

  • model: It is an array of menu items. It is of an array type of data & the default value is null.
  • activeIndex: It is the index of the active item. It accepts the number as an input data type & the default value is 0.
  • readonly: It specifies whether the items are clickable or not. It is of the boolean data type & the default value is true.
  • style: It sets the inline style of the component. It is of the string data type & the default value is null.
  • styleClass: It is the style class of the component. It is of the string data type & the default value is null.

 

Creating Angular application & module installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: It will look like the following:

 

Steps to run the application: Run the below command to see the output:

ng serve --open

Example 1: Below is the example code that illustrates the use of the Angular PrimeNG Steps Properties.

  • app.component.html:

HTML




<h2 style="color: green">GeeksforGeeks</h2>
<h4>Angular PrimeNG Steps Properties</h4>
<p-steps
    [model]="[
        { label: 'DSA' },
        { label: 'Algorithm' },
        { label: 'Web Tech' },
        { label: 'Aptitude' }
    ]"
    [(activeIndex)]="gfg"
    [readonly]="false">
</p-steps><br />
<button (click)="chan()">----></button>


  • app.component.ts:

Javascript




import { Component } from "@angular/core";
import { MenuItem } from "primeng/api";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
})
  
export class AppComponent {
    geeks: MenuItem[];
    gfg: number = 0;
  
    chan() {
        this.gfg += 1;
    }
    ngOnInit() {}
}


  • app.module.ts:

Javascript




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { RouterModule } from "@angular/router";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { StepsModule } from "primeng/steps";
import { ToastModule } from "primeng/toast";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        StepsModule,
        ToastModule,
        RouterModule.forRoot([{ 
            path: "",
            component: AppComponent 
        }]),
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule {}


Output:

 

Example 2: Below is another example code that illustrates the use of the Angular PrimeNG Steps Properties using readonly=”true”.

  • app.component.html:

HTML




<h2 style="color: green">GeeksforGeeks</h2>
<h4>Angular PrimeNG Steps Properties</h4>
<p-steps
    [model]="[
        { label: 'DSA' },
        { label: 'Algorithm' },
        { label: 'Web Tech' },
        { label: 'Aptitude' }
    ]"
    [(activeIndex)]="gfg"
    [readonly]="true">
</p-steps><br />


  • app.component.ts:

Javascript




import { Component } from "@angular/core";
import { MenuItem } from "primeng/api";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
})
export class AppComponent {
    geeks: MenuItem[];
    gfg: number = 1;
  
    chan() {
        this.gfg += 1;
    }
    ngOnInit() {}
}


  • app.module.ts:

Javascript




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { RouterModule } from "@angular/router";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { StepsModule } from "primeng/steps";
import { ToastModule } from "primeng/toast";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        StepsModule,
        ToastModule,
        RouterModule.forRoot([{ 
            path: "",
            component: AppComponent 
        }]),
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule {}


Output:

 

Reference: https://primefaces.org/primeng/steps/personal



Last Updated : 02 Nov, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads