- Items as tag directive
- Items based on current Url
- Static URL
- Customize text when generated items using Url
Contact Support
Data binding in Angular Breadcrumb component
27 Apr 20246 minutes to read
Items as tag directive
The Angular Breadcrumb contains e-breadcrumb-items
and e-breadcrumb-item
tags to render items for the component. To bind items, use e-breadcrumb-items
tag and e-breadcrumb-item
tag to bind properties for breadcrumb items.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { BreadcrumbModule } from '@syncfusion/ej2-angular-navigations'
import { Component } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
@Component({
imports: [ BreadcrumbModule],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<!-- To Render Breadcrumb with items. -->
<ejs-breadcrumb [enableNavigation]="false">
<e-breadcrumb-items>
<e-breadcrumb-item text="Home" url="https://ej2.syncfusion.com/home/angular.html"></e-breadcrumb-item>
<e-breadcrumb-item text="Components" url="https://ej2.syncfusion.com/angular/demos/#/material/grid/over-view"></e-breadcrumb-item>
<e-breadcrumb-item text="Navigations" url="https://ej2.syncfusion.com/angular/demos/#/material/breadcrumb/default"></e-breadcrumb-item>
<e-breadcrumb-item text="Breadcrumb" url="./breadcrumb/default"></e-breadcrumb-item>
</e-breadcrumb-items>
</ejs-breadcrumb></div>`
})
export class AppComponent {}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Items based on current Url
The breadcrumb items can be generated from the current URL of the page, if the url
property is not provided or when the user does not specify the breadcrumb items using the BreadcrumbItemDirective tag. The following example shows the breadcrumb items that are generated based on the current URL.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { BreadcrumbModule } from '@syncfusion/ej2-angular-navigations'
import { Component } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
@Component({
imports: [ BreadcrumbModule],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<!-- To Render Breadcrumb. -->
<ejs-breadcrumb [enableNavigation]="false"></ejs-breadcrumb></div>`
})
export class AppComponent {}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
This sample is hosted in different location, so the Breadcrumb Component is rendered with different location instead of the actual location.
Static URL
The breadcrumb items can be generated by providing the url
property in the component, if the user does not specify the breadcrumb items using the BreadcrumbItemDirective tag. The following example shows the breadcrumb items generated from the provided url in the component.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { BreadcrumbModule } from '@syncfusion/ej2-angular-navigations'
import { Component } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
@Component({
imports: [ BreadcrumbModule],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<!-- To Render Breadcrumb. -->
<ejs-breadcrumb [enableNavigation]="false" url="https://ej2.syncfusion.com/angular/demos/breadcrumb/bind-to-location"></ejs-breadcrumb></div>`
})
export class AppComponent {}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Customize text when generated items using Url
The breadcrumb items text can be customized by using the beforeItemRender
event. In the following example, bind-to-location
text was customized as location
.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { BreadcrumbModule } from '@syncfusion/ej2-angular-navigations'
import { Component } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
import { BreadcrumbBeforeItemRenderEventArgs } from '@syncfusion/ej2-navigations';
enableRipple(true);
@Component({
imports: [ BreadcrumbModule],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<!-- To Render Breadcrumb with items. -->
<ejs-breadcrumb [enableNavigation]="false" (beforeItemRender)="beforeItemRenderHandler($event)" url="https://ej2.syncfusion.com/angular/demos/breadcrumb/bind-to-location"></ejs-breadcrumb></div>`
})
export class AppComponent {
beforeItemRenderHandler(args: BreadcrumbBeforeItemRenderEventArgs): void {
if (args.item.text === 'bind-to-location') {
args.item.text = 'location';
}
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));