npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-breadcrumbs-go

v1.0.10

Published

Breadcrumb generator for Angular

Downloads

8

Readme

ngx-breadcrumbs-go

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

Demo

Usage

Getting started

1.Install ngx-breadcrumbs-go via npm:

npm install --save ngx-breadcrumbs-go

2.Import the BreadcrumbsModule within your app:

import {BreadcrumbsModule} from "ngx-breadcrumbs-go";

@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' and storePrefixed` 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).