Open In App

Angular PrimeNG Steps Readonly

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 Readonly 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. The readonly property is used to check whether the items are clickable or not.

Syntax:

<p-steps 
    [model]="..."
    [(activeIndex)]="..." 
    [readonly]="...">
</p-steps>

 

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: This is the basic example that illustrates how to use the Angular PrimeNG Steps Readonly using readonly=”true”.

  • app.component.html:

HTML




<h2>GeeksforGeeks</h2>
<h4>PrimeNG Steps ReadOnly</h4>
<p-steps 
    [model]="geeks"
    [(activeIndex)]="gfg" [readonly]="true">
</p-steps>


  • 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;
  
    ngOnInit() {
        this.geeks = [
            { label: "PrimeNG" },
            { label: "AngularJS" },
            { label: "ReactJS" },
            { label: "HTML" },
        ];
    }
}


  • 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: This is the basic example that illustrates how to use the Angular PrimeNG Steps Readonly using readonly=”false”.

  • app.component.html:

HTML




<h2>GeeksforGeeks</h2>
<h4>PrimeNG Steps ReadOnly</h4>
<p-steps 
    [model]="geeks"
    [(activeIndex)]="gfg" [readonly]="false">
</p-steps>


  • 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;
  
    ngOnInit() {
        this.geeks = [
            { label: "PrimeNG" },
            { label: "AngularJS" },
            { label: "ReactJS" },
            { label: "HTML" },
        ];
    }
}


  • 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