Open In App

Angular PrimeNG Steps Properties

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:

 



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.




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




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() {}
}




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




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




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() {}
}




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


Article Tags :