All Projects → hggeorgiev → Ng2 Breadcrumbs

hggeorgiev / Ng2 Breadcrumbs

Licence: mit
A breadcrumb service for the Angular 7 router

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ng2 Breadcrumbs

Ng2 Search Filter
Angular 2 / Angular 4 / Angular 5 custom pipe npm module to make a search filter on any input, 🔥 100K+ downloads
Stars: ✭ 137 (+124.59%)
Mutual labels:  ng2, angular2, angular5
Angular Google Maps
Angular 2+ Google Maps Components
Stars: ✭ 1,982 (+3149.18%)
Mutual labels:  ng2, angular2, angular5
Angular
UI-Router for Angular: State-based routing for Angular (v2+)
Stars: ✭ 287 (+370.49%)
Mutual labels:  router, ng2, angular2
Angular Prest
pREST component for Angular
Stars: ✭ 16 (-73.77%)
Mutual labels:  angular2, angular5
Angular Froala Wysiwyg
Angular 4, 5, 6, 7, 8 and 9 plugin for Froala WYSIWYG HTML Rich Text Editor.
Stars: ✭ 696 (+1040.98%)
Mutual labels:  angular2, angular5
Ngx Permissions
Permission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible
Stars: ✭ 749 (+1127.87%)
Mutual labels:  angular2, angular5
Angular Material App
基于最新Angular 9框架与Material 2技术的web中后台前端应用框架。
Stars: ✭ 509 (+734.43%)
Mutual labels:  angular2, angular5
Nebular
💥 Customizable Angular UI Library based on Eva Design System 🌚✨Dark Mode
Stars: ✭ 7,368 (+11978.69%)
Mutual labels:  angular2, angular5
Angular Skeleton App
Angular 7.x navigation skeleton project with styling which get you started faster.
Stars: ✭ 25 (-59.02%)
Mutual labels:  navigation, angular5
Angularconcepts
Key Angular Concepts using Latest Angular version 5
Stars: ✭ 31 (-49.18%)
Mutual labels:  router, angular5
Ng2 Pdf Viewer
📄 PDF Viewer Component for Angular 5+
Stars: ✭ 997 (+1534.43%)
Mutual labels:  angular2, angular5
Navaid
A navigation aid (aka, router) for the browser in 850 bytes~!
Stars: ✭ 648 (+962.3%)
Mutual labels:  router, navigation
Angular2 Mdl
Angular 2, 4, 5, 6, 7, 8, 9, 10, 11 components, directives and styles based on material design lite (npm: @angular-mdl/core)
Stars: ✭ 562 (+821.31%)
Mutual labels:  angular2, angular5
Ngx Echarts
An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
Stars: ✭ 820 (+1244.26%)
Mutual labels:  ng2, angular2
Ngx Admin
Customizable admin dashboard template based on Angular 10+
Stars: ✭ 23,286 (+38073.77%)
Mutual labels:  ng2, angular2
Angular2 Carousel
An lightweight , touchable and responsive library to create a carousel for angular 2 / 4 / 5
Stars: ✭ 26 (-57.38%)
Mutual labels:  ng2, angular2
Ng2 Ace
A basic ace editor directive for angular 2.
Stars: ✭ 33 (-45.9%)
Mutual labels:  ng2, angular2
Angular Tree Component
A simple yet powerful tree component for Angular (>=2)
Stars: ✭ 1,031 (+1590.16%)
Mutual labels:  angular2, angular5
Ng2 Sweetalert2
A sweetalert2 service for angular2.
Stars: ✭ 49 (-19.67%)
Mutual labels:  ng2, angular2
Router
🛣 Simple Navigation for iOS
Stars: ✭ 438 (+618.03%)
Mutual labels:  router, navigation

ng2-breadcrumbs

npm version

ng2-breadrumbs is a module for Angular 7 that generates a breadcrumb for any page of your application. It is based on the built-in Angular 7 router.

Demo

Usage

Getting started

1.Install ng2-breadcrumbs via npm:

npm install --save ng2-breadcrumbs

2.Import the BreadcrumbsModule within your app:

import {BreadcrumbsModule} from "ng2-breadcrumbs";

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

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

export const ROUTES: Routes = [
    {path: '', redirectTo: 'home', pathMatch: 'full'},
    {
        path: 'home',
        loadChildren: 'app/home/home.module#HomeModule',
        data: {
            breadcrumb: 'Home'
        }
    },
    {
        path: 'stores',
        loadChildren: 'app/stores/stores.module#StoresModule',
        data: {
            breadcrumb: 'Stores'
        }
    }
];

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

<breadcrumb [allowBootstrap]="true"></breadcrumb>
<router-outlet></router-outlet>
  1. Then your StoresModule's routes will look like this:
const STORE_ROUTES: Routes = [
    {
        path: '',
        component: StoresComponent
    },
    {
        path: 'books',
        data: {
            breadcrumb: 'Books'
        },
        loadChildren: 'app/books/books.module#BooksModule'
    }

];

Adding dynamic routes

In case you want a dynamic breadcrumb name, you can pass it as a :breadcrumb route parameter when navigating: Route:

//Add an extra route parameter that will contain the breadcrumb name
const BOOK_ROUTES: Routes = [
    {
        path: '',
        component: BooksComponent
    },
    {
        path: 'book/:id/:breadcrumb',
        component: BookComponent
    }
];

Router code:

    public goToBook(book: Book) {
        this.router.navigate(['book' , book.Id, book.Name], { relativeTo: this.route });
    }

Adding routes manually

In case the router configuration does not satisfy the way you want to design your breadcrumb structure, you can do it manually through BreadcrumbsService. You can add your custom breadcrumbs through your route's routable component, for example:

export class MyRoutableComponent {
  constructor( private breadcrumbsService:BreadcrumbsService) {
  }

  ngOnInit() {
    this.breadcrumbs.store([{label: 'Home' , url: '/', params: []},{label: 'Careers' , url: '/careers', params: []}, {label:  'MyCustomRouteLabel' , url: '', params: []} ])
  }
}

Prefixing routes

Suppose that you already have your breadcrumbs generated, but due to the nesting of the routers, you want to add a breadcrumb from the parent router:

this.breadcrumbs.storePrefixed({label: 'Home' , url: '/', params: []})

Breadcrumb format

The BreadcrumbsService's store' andstorePrefixed` methods breadcrumb objects. A breadcrumb object should contain:

  • label - The text displayed on the breadcrumb
  • url - The link that it leads to
  • params - A collection of route parameters

TODO

  1. Add more use cases (using routerLinks, for example).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].