Open In App

Angular PrimeNG Breadcrumb Properties

Last Updated : 19 Dec, 2022
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 Breadcrumb Properties in Angular PrimeNG.

The Breadcrumb Component provides the navigation link that is used to link the previous pages the user navigates through & displays it in the hierarchy.

Angular PrimeNG Breadcrumb Properties:

  • model: It is an array of menu items to be shown. It is of array data type, the default value is null.
  • home: It is the menuItem configuration for the home icon. It is of MenuItem type, the default value is null.
  • style: It is the inline style of the component. It is of string data type, the default value is null.
  • styleClass: It is the style class of the component. It is of string data type, the default value is null.
  • homeAriaLabel: It is used to define the string that labels the home icon for accessibility. It is of string type and its 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:

 

To run the above file run the below command:

ng serve --save

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

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Breadcrumb Properties</h5>
<p-breadcrumb 
    [model]="gfg" 
    [home]="home">
</p-breadcrumb>


  • 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 {
    gfg: MenuItem[];
  
    ngOnInit() {
        this.gfg = [
            { label: "C++ STL" },
            { label: "System Design" },
            { label: "DSA Self-Paced" },
            { label: "OOP's" },
            { label: "DBMS" }
        ];
    }
}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent }   from './app.component';
import { BreadcrumbModule } from 'primeng/breadcrumb';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        BreadcrumbModule
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Example 2: Below is another example code that illustrates the use of Angular PrimeNG Breadcrumb Properties.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Breadcrumb Properties.</h5>
<p-breadcrumb 
    [model]="[
        {label: 'React JS'},
        {label: 'Functional Component'},
        {label: 'React Hooks'},
    ]" 
    [home]="{icon: 'pi pi-home'}">
</p-breadcrumb>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
  
export class AppComponent { }


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent }   from './app.component';
import { BreadcrumbModule } from 'primeng/breadcrumb';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        BreadcrumbModule
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Reference: https://primefaces.org/primeng/breadcrumb



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads