8.0.0 • Published 2 years ago

ng7-bootstrap-breadcrumb v8.0.0

Weekly downloads
206
License
MIT
Repository
github
Last release
2 years ago

ng7-bootstrap-breadcrumb

ng7-bootstrap-breadcrumb is a Angular 14 bootstrap module for Angular that generates a Angular7 bootstrap breadcrumb for any page of your application. It is based on the built-in Angular router.

Demo Example

Demo Source Example

Usage

Getting started

1.Install ng7-bootstrap-breadcrumb via npm:

npm install --save ng7-bootstrap-breadcrumb

Choose the version corresponding to your Angular version:

Angularng7-bootstrap-breadcrumb
148.x+
126.x+
115.x+
104.x+
93.x+
82.x+
71.x

2.Import the Ng7BootstrapBreadcrumbModule within your app:

import {Ng7BootstrapBreadcrumbModule} from "ng7-bootstrap-breadcrumb";

@NgModule({
  imports: [
    Ng7BootstrapBreadcrumbModule,
  ],
})

3.Add a name to your route by adding a breadcrumb property in the route's data:

const routes: Routes = [
  {
    path: 'page1/:pageOneID',
    component: PageComponent,
    data: {
      title: 'page1',
      breadcrumb: [
        {
          label: 'Page1',
          url: ''
        }
      ]
    },
  },
  {
    path: 'page1/:pageOneID/page2/:pageTwoID',
    component: Page2Component,
    data: {
      title: 'page2', 
      breadcrumb: [
        {
          label: 'page {{pageOneID}}',// pageOneID Parameter value will be add 
          url: '/page1/:pageOneID'
        },
        {
          label: 'page {{pageTwoID}}',// pageTwoID Parameter value will be add 
          url: ''
        }
      ]
    },
  },
  {
    path: 'page1/:pageOneID/page2/:pageTwoID/page3/:pageThreeID',
    component: Page3Component,
    data: {
      title: 'page3',
      breadcrumb: [
        {
          label: 'page1',
          url: '/page1/:pageOneID'
        },
        {
          label: '{{dynamicText}} page', // If "dynamicText" is not parameter , should be set value  using Ng7MatBreadcrumbService, More info please check the 5th point.
          url: 'page1/:pageOneID/page2/:pageTwoID'
        },
        {
          label: '{{customText}}', // If "customText" is not parameter , should be set value  using Ng7MatBreadcrumbService, More info please check the 5th point.
          url: ''
        }
      ]
    },
  },
];

4.Put the Ng7DynamicBreadcrumbComponent's selector within your template:

<app-ng7-bootstrap-breadcrumb></app-ng7-bootstrap-breadcrumb>
<router-outlet></router-outlet>

Input parameters

InputRequiredDetails
bgColorOptionalTo set background-color for Breadcrumb, default #eee
fontSizeOptionalTo set size of Breadcrumb, default 18px
fontColorOptionalTo set color of Breadcrumb, default #0275d8
lastLinkColorOptionalTo set color of last link Breadcrumb, default #000
symbolOptionalTo set symbol of Breadcrumb, default /

5.Set the value using Ng7BootstrapBreadcrumbService

import { Ng7BootstrapBreadcrumbService } from 'ng7-bootstrap-breadcrumb';
constructor(private ng7BootstrapBreadcrumbService: Ng7BootstrapBreadcrumbService) { }
ngOnInit() {
  const breadcrumb =  {customText: 'This is Custom Text', dynamicText: 'Level 2 '};
  this.ng7BootstrapBreadcrumbService.updateBreadcrumbLabels(breadcrumb);
  }
  1. Update the Breadcrumb using Ng7MatBreadcrumbService
import { Ng7BootstrapBreadcrumbService } from 'ng7-bootstrap-breadcrumb';
constructor(private ng7BootstrapBreadcrumbService: Ng7BootstrapBreadcrumbService) { }

  updateBreadcrumb(): void {
    const breadcrumbs  =  [
      {
        label: 'page {{pageOneID}}',
        url: '/page1/:pageOneID'
      },
      {
        label: 'page {{pageTwoID}}',
        url: 'page1/:pageOneID/page2/:pageTwoID'
      },
      {
        label: 'page {{pageThreeID}}',
        url: 'page1/:pageOneID/page2/:pageTwoID/page3/:pageThreeID'
      },
      {
        label: 'Update Breadcrumb',
        url: ''
      }
    ];
    this.ng7BootstrapBreadcrumbService.updateBreadcrumb(breadcrumbs);
  }

Questions & Issues

Report bugs/problems by creating an issue creating an issue

Contribute

Pick one of the issues from the issue list to get started.

Developer

Developer: Raja Rama Mohan Thavalam

Raja Rama Mohan Thavalam
Raja Rama Mohan Thavalam

License

(The MIT License)

Copyright (c) 2022 Thavalam Raja Rama Mohan