Giter Club home page Giter Club logo

ngx-breadcrumbs's Introduction

Ngx-Breadcrumbs

An Angular (4+) module generating breadcrumbs based on the routing state.

THIS PROJECT IS NOT MAINTAINED ANYMORE

Installation

# install via npm
$ npm --save install ngx-breadcrumbs
# install via yarn
$ yarn add ngx-breadcrumbs

Usage

Import the McBreadcrumbsModule in your root module (app.module.ts) after importing the router module.

import { RouterModule } from '@angular/router';
import { McBreadcrumbsModule } from 'ngx-breadcrumbs';

@NgModule({
  imports: [
    RouterModule.forRoot(myRoutes),
    McBreadcrumbsModule.forRoot()
  ],  
})
export class AppModule {}

Place the mc-breadcrumbs component, which will render the breadcrumbs, somewhere in your markup.

@Component({
  selector: 'app-root',
  template: `
    <div class="container">
      <mc-breadcrumbs></mc-breadcrumbs>
      <router-outlet></router-outlet>
    </div>`
})
export class AppComponent {}

Usage of the mc-breadcrumbs render component is optional. If a different markup output is desired, a custom component can be created that subscribes to the McBreadcrumbsService.crumbs$ observable.

Routing Configuration

Breadcrumbs links are generated based on the route configuration. If a route entry contains a data.breadcrumbs property the breadcrumbs service assumes breadcrumbs should be created whenever this route or one its child routes are active.

const myRoutes : Route[] = {
  {
    path: '',
    component: HomeComponent,
    data: {
      // Uses static text (Home)
      breadcrumbs: 'Home' 
    }
  },
  {
    path: 'about',
    component: AboutComponent,
    data: {
      // Uses last urlfragment (about) as text
      breadcrumbs: true 
    }
  },
  {
    path: 'person',
    data: {
      // Uses text property (Person)
      breadcrumbs: true,
      text: 'Person'
    },
    children: [
      {
          path: '',
          component: PersonListComponent
      },
      {
          path: ':id',
          component: PersonDetailComponent,
          data: {
            // Interpolates values resolved by the router 
            breadcrumbs: '{{ person.name }}'
          },
          resolve: {
            person: PersonResolver
          }
      } 
    ]
  },    
  {
    path: 'folder',
    data: {
      // Uses static text 'Folder'
      breadcrumbs: 'Folder'
    },
    children: [
      {
      path: '',
      component: FolderComponent
      },
      {
        path: ':id',
        component: FolderComponent,
        data: {
          // Resolves the breadcrumbs for this route by
          // implementing a McBreadcrumbsResolver class.
          breadcrumbs: FolderBreadcrumbsResolver
        }
      }
    ]
  }
};

API

IBreadcrumb

The IBreadcrumb interface defines the properties of the breadcrumb items.

export interface IBreadcrumb {
  text: string,  // The text to display 
  path: string   // The associated path
}

McBreadcrumbsComponent

The component simply renders the list of the IBreadcrumb items provided by the McBreadcrumbsService. The HTML output matches that of Bootstrap 4 markup.

A custom breadcrumb component is easily created by injecting the breadcrumb service and iterating over the breadcrumb items.

McBreadcrumbsService

The service has one public property crumbs$. It's an observable stream of IBreadcrumb[], which is updated after each route change.

McBreadcrumbsResolver

If needed, a custom resolver can be implemented which is activated whenever a certain route becomes active. This can be useful whenever the route configuration cannot match the desired breadcrumb hierachy.

The signature of the resolver implements Resolve<T> from the Angular Router and needs to resolve an array of IBreadcrumb items.

To associate a route with a certain resolver, it breadcrumbs data property in the route configuration should point to the resolver:

const myRoutes = [
  {
    path: 'somepath',
    component: SomeComponent,
    data: {
      breadcrumbs: MyBreadcrumbsResolver
    }
  }
];
Members
// Should resolve zero or more IBreadcrumb items.
function resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot)
  : Observable<T>|Promise<T>|T 
// Helper function that returns the full path for the provided route snapshot.
function getFullPath(route: ActivatedRouteSnapshot) 
  : string
Example
@Injectable()
export class MyBreadcrumbsResolver inherits McBreadcrumbsResolver {

  // Optional: inject any required dependencies
  constructor(private myService: MyService) {}

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    
    const myFolderId = route.params.id;
    const myCrumbs = 
      this.myService.getFolders(myFolderId)
                    .map((folder) => ({
                      text: folder.title,
                      path: super.getFullPath(route.parent) + '/' + folder.id
                    });

    // Note: the resolve method can return any of the following types:
    //
    //   * IBreadcrumb[]
    //   * Observable<IBreadcrumb[]>
    //   * Promise<IBreadcrumb>

    return myCrumbs; 
  }
}

McBreadcrumbsConfig

The configuration of the breadcrumbs module.

Members

postProcess

Callback function with the following signature:

function (crumbs: IBreadcrumb[]) : Promise<IBreadcrumb[]> | Observable<IBreadcrumb[]> | IBreadcrumb[];

Can be used to make custom changes to the breadcrumb array after the service has constructed the breadcrumb trail.

Example:

@NgModule({
  /* ... */
})
export class AppModule {
  constructor(breadcrumbsConfig: McBreadcrumbsConfig) {

    breadcrumbsConfig.postProcess = (x) => {

      // Ensure that the first breadcrumb always points to home

      let y = x;

      if(x.length && x[0].text !== 'Home') {
        y = [
          {
            text: 'Home',
            path: ''
          }
        ].concat(x);
      }

      return y;
    };
  }
}

ngx-breadcrumbs's People

Contributors

angular-cli avatar mcnull avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-breadcrumbs's Issues

McBreadcrumbsConfig.postProcess nullable

Hello,

I think the definition of McBreadcrumbsConfig.postProcess should be IPostProcessFunc | null | undefined to be able to reset it without Typescript compilation error.

A workaround is to assign an empty function but it's a shame: the code actually works with null or undefined.

I can make a PR if you agree but I think it will be longer to review it rather than changing it directly.

Child routes

I'm just wondering if this is even possible.

I have a 'Manage Users' route. I also have an 'Edit User' route. I didn't explicitly put the 'Edit User' route as a child of 'Manage Users', because putting a wouldn't make sense in this specific scenario.

However, when you edit a user, the route appears as so: "manage_users/edit_user". When I am on the 'Edit User' route, I am unable to get the breadcrumb bar to display:

Manage Users / Edit User

I believe this is because of the way I have things structured. Is there any way I can get the breadcrumb bar to behave the way I want without adding an actual child route?

Using Resolver in routes

Hello, i've used this tutorial to get familar with AngularJs.
Breadcrumbs are working, except the part with the resolver.
How does a Resolver has to look for this lib? Already tried to use the Resolver from the repo but i still got the message that person is undefined.

I would be grateful for help

My Resolver (for testing)

    import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
    import { Injectable } from '@angular/core';
    import { IRecipe } from "../_class/person";

    @Injectable()
    export class PersonResolver implements Resolve<IRecipe> {

    constructor(private service: PersonService) { }

    public resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<IPerson> {

        const id = route.params.id;

        if (id) {
            return Promise.resolve({
                id: 900,
                title: "666666"
            });
        } else {
            return Promise.resolve({
                id: 0,
                title: ""
            });
        }
    }
    }

Error on install

Hello,

when I install:
npm --save install ngx-breadcrumbs

I get this error:

npm ERR! asyncWrite is not a function
npm ERR! processNextTick is not a function

Thanks.

Not maintained

Hi @peterbsmith2

why is the project out of maintenance?

I could probably take it over

Angular 5.x.x compatibility?

Is this module 5.x.x compliant?
My package.json

{
    "@angular/router": "^5.1.0",
    "@angular/core": "^5.1.0",
}
$ npm --save install ngx-breadcrumbs

npm WARN [email protected] requires a peer of @angular/core@>=4.0.0 <5.0.0 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/router@>=4.0.0 <5.0.0 but none is installed. You must install peer dependencies yourself.

Breadcrumbs not displaying with resolver

Can anyone help me out here? I have a custom Breadcrumb resolver to get names of events and there units from dynamic data, logging shows the array of breadcrumbs is compiled correctly but I only get a "1." displayed where the breadcrumb is supposed to be.

Is the following the correct way to return Observable<IBreadcrumb[]>?

I am using Angular 6 and have used the git repo and built out the Angular 6 converted version.

BreadcrumbResolver

import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { IBreadcrumb, McBreadcrumbsResolver } from 'ngx-breadcrumbs';
import { EventsService } from './events.service';
import { EventModel } from '../Models/event.model';
import { Observable } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class BreadcrumbResolver extends McBreadcrumbsResolver {
  private event: EventModel;
  constructor( private router: Router, private eventsService: EventsService) { super(); }

  resolve (route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<IBreadcrumb[]> {
    const breadCrumbs: Array<IBreadcrumb> = [];
    return new Observable((observer) => {
      this.eventsService.getEvent(route.params.id || route.parent.params.id).subscribe( (event) => {
        if (route.params.unitId || route.parent.params.unitId) {
          breadCrumbs.push({
            text: event.name,
            path: this.router.createUrlTree(['events', event._id]).toString()
          });
          let unitName = '';
          event.courses.forEach( (course) => {
            if (course !== null) {
              const foundUnit = course.units.find((unit) => {
                return unit.id === (route.params.unitId || route.parent.params.unitId);
              });
              if (foundUnit) {
                unitName = foundUnit.name;
                breadCrumbs.push({
                  text: unitName,
                  path: this.router.createUrlTree(['events', event._id]).toString()
                });
              }
            }
          });
          observer.next(breadCrumbs);
        } else {
          // no unit id available so we just need to event breadcrumb
          breadCrumbs.push({ text: event.name, path: this.router.createUrlTree(['events', event._id]).toString() });
          observer.next(breadCrumbs);
        }
      });
      return observer.complete();
    });
  }
}

Routing Module

const eventsRoutes: Routes = [
  {
    path: '',
    component: EventsComponent,
    data: {title: 'Events', breadcrumbs: 'Events'},
    canActivate: [AuthGuardService]
  },
  {
    path: ':id',
    component: EventComponent,
    data: {title: 'Event'},
    children: [
      {
        path: 'overview',
        component: OverviewComponent,
        data: {title: 'Event Overview', breadcrumbs: BreadcrumbResolver}
      },
      {
        path: 'participants',
        component: ParticipantsComponent,
        data: {title: 'Event Participants', breadcrumbs: BreadcrumbResolver}
      },
      {
        path: 'assessments',
        component: AssessmentsComponent,
        data: {title: 'Event Assessments', breadcrumbs: BreadcrumbResolver}
      }
    ]
  },
  {
    path: ':id/assessments/:unitId',
    component: LearningAssessmentComponent,
    data: {title: 'Learning Assessment', breadcrumbs: BreadcrumbResolver},
  },
];

Logged breadcrumbs
image

How it looks in the DOM
image

Ran into some error

I have a multilayered angular app which has lets say app as the root module, then crm as the nested module. Now since my breadcrumb sits in the 'crm.component.html' and the routes served after this I made the following changes to the suggested method of installing

Used npm to install, got this warning in the log

npm WARN [email protected] requires a peer of lodash.template@^4.4.0 but none was installed.

The structure of my app is like this

  • app module
    |--crm module (has all the page styling, headers, breadcrumbs etc)
    |--login component

I followed the install instructions like this

  1. Added the import statements in crm.module.ts like this

import { McBreadcrumbsModule } from 'ngx-breadcrumbs';

@NgModule({
  imports: [
    CommonModule,
    CrmRoutingModule,
    McBreadcrumbsModule.forRoot(),
  ],
  declarations: [
    CrmComponent,
    BreadcrumbComponent,
    NavigationComponent,
    RightSidebarComponent,
    SidebarComponent,
  ]
}) 
  1. Added the in crm.component.html
<div id="wrapper">
  <ma-navigation></ma-navigation>
  <ma-sidebar></ma-sidebar>
  <div id="page-wrapper">
    <div class="container-fluid">
      <mc-breadcrumbs></mc-breadcrumbs>
      <ma-rightsidebar></ma-rightsidebar>
    </div>
    <footer class="footer">
     
    </footer>

  </div>
</div>
  1. Error I get while serving the app
ERROR in ./node_modules/ngx-breadcrumbs/ngx-breadcrumbs/ngx-breadcrumbs.es5.js
Module not found: Error: Can't resolve 'lodash.template' in '/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs'
resolve 'lodash.template' in '/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs'
  Parsed request is a module
  using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/package.json (relative path: ./ngx-breadcrumbs)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/package.json (relative path: ./ngx-breadcrumbs)
    resolve as module
      /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs/node_modules doesn't exist or is not a directory
      /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/node_modules doesn't exist or is not a directory
      /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/node_modules doesn't exist or is not a directory
      /Applications/MAMP/htdocs/node_modules doesn't exist or is not a directory
      /Applications/MAMP/node_modules doesn't exist or is not a directory
      /Applications/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules/lodash.template)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template doesn't exist
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules/lodash.template)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template doesn't exist
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/src
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src/lodash.template)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template doesn't exist
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/src
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src/lodash.template)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template doesn't exist
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs/node_modules]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/node_modules]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/node_modules]
[/Applications/MAMP/htdocs/node_modules]
[/Applications/MAMP/node_modules]
[/Applications/node_modules]
[/node_modules]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.template]
 @ ./node_modules/ngx-breadcrumbs/ngx-breadcrumbs/ngx-breadcrumbs.es5.js 13:0-44
 @ ./src/app/crm/crm.module.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
ERROR in ./node_modules/ngx-breadcrumbs/ngx-breadcrumbs/ngx-breadcrumbs.es5.js
Module not found: Error: Can't resolve 'lodash.templatesettings' in '/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs'
resolve 'lodash.templatesettings' in '/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs'
  Parsed request is a module
  using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/package.json (relative path: ./ngx-breadcrumbs)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/package.json (relative path: ./ngx-breadcrumbs)
    resolve as module
      /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs/node_modules doesn't exist or is not a directory
      /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/node_modules doesn't exist or is not a directory
      /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/node_modules doesn't exist or is not a directory
      /Applications/MAMP/htdocs/node_modules doesn't exist or is not a directory
      /Applications/MAMP/node_modules doesn't exist or is not a directory
      /Applications/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules/lodash.templatesettings)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings doesn't exist
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./node_modules/lodash.templatesettings)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings doesn't exist
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/src
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src/lodash.templatesettings)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings doesn't exist
      looking for modules in /Applications/MAMP/htdocs/supreme_frontend_crm/src
        using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src)
          using description file: /Applications/MAMP/htdocs/supreme_frontend_crm/package.json (relative path: ./src/lodash.templatesettings)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.js doesn't exist
            as directory
              /Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings doesn't exist
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/ngx-breadcrumbs/node_modules]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/ngx-breadcrumbs/node_modules]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/node_modules]
[/Applications/MAMP/htdocs/node_modules]
[/Applications/MAMP/node_modules]
[/Applications/node_modules]
[/node_modules]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/node_modules/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.ts]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings.js]
[/Applications/MAMP/htdocs/supreme_frontend_crm/src/lodash.templatesettings]
 @ ./node_modules/ngx-breadcrumbs/ngx-breadcrumbs/ngx-breadcrumbs.es5.js 14:0-60
 @ ./src/app/crm/crm.module.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

Angular 8 support

PS C:\github\super_secret_app> ng update @angular/cli @angular/core
Your global Angular CLI version (8.1.2) is greater than your local
version (7.3.8). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
                  Package "ngx-breadcrumbs" has an incompatible peer dependency to "@angular/core" (requires ">=4.0.0 <5.0.0 || >=4.0.0-beta <5.0.0" (extended), would install "8.2.2").
                  Package "ngx-breadcrumbs" has an incompatible peer dependency to "@angular/router" (requires ">=4.0.0 <5.0.0" (extended), would install "8.2.2").
Incompatible peer dependencies found. See above.

Rxjs Observable Issue

With the current library on line 3 of ngx-breadcrumbs.es5.js:

import { Observable as Observable$1 } from 'rxjs/Observable';
giving error:

ERROR TypeError: rxjs_Observable__WEBPACK_IMPORTED_MODULE_2__.Observable.of is not a function
at McBreadcrumbsService.push../node_modules/ngx-breadcrumbs/ngx-breadcrumbs/ngx-breadcrumbs.es5.js.McBreadcrumbsService._resolveCrumbs

and breadcrumb not shown.

But after changing into:
import { Observable as Observable$1 } from 'rxjs';

It's doing good again.

refresh issue

When refresh the page, the breadcrumb is not showing.

Feature: override template

Hello,

First of all, thank you for your library.

I've been playing around with all the functionalities and I found It would be a nice feature being able to override the breadcrumb template. It would be very useful for adding a trailing chevron on every linkable item, avoiding this chevron of being linkable.

In this case is not valid the resolver because it doesn't render the injected html on 'text' field nor using an ::after on css because it comes linkable too.

Thank you

padding for the last element

Hello,

thanks for your effort on that cool component :)
would you please add a padding between the / and the last element in the menu.

Happy Coding!

Unable to upgrade @angular/core

ng update @angular/core
Package "ngx-breadcrumbs" has an incompatible peer dependency to "@angular/core" (requires ">=5.0.0-rc.0 <6.0.0||>=4.0.0 <5.0.0||>=4.0.0-beta <5.0.0", would install "6.0.5").
Package "ngx-breadcrumbs" has an incompatible peer dependency to "@angular/router" (requires ">=5.0.0-rc.0 <6.0.0||>=4.0.0 <5.0.0", would install "6.0.5").
Incompatible peer dependencies found. See above.

Angular 6

when using npm install ngx-breadcrumbs , it installs the version for angular 5
when using npm install https://github.com/McNull/ngx-breadcrumbs.git to get the latest version , it saying there is no module called ngx-breadcrumbs when importing in the app .
it also shows this error :
ERROR in node_modules/ngx-breadcrumbs/src/lib/mc-breadcrumbs/src/mc-breadcrumbs.shared.ts(22,27): error TS2307: Cannot find module 'lodash.template'.
node_modules/ngx-breadcrumbs/src/lib/mc-breadcrumbs/src/mc-breadcrumbs.shared.ts(23,35): error TS2307: Cannot find module 'lodash.templatesettings'.

Multiple breadcrumbs being shown none are correct

My issue is that I get two breadcrumbs being displayed, one with a link to the root and another which is always plain text. This image should illustrate this issue better:
image

Routes.ts
{ path: 'products', data: { text: 'Products', nav: true, breadcrumbs: true }, children: [ { path: '', component: ProductDirectoryComponent, }, { path: ':group', component: ProductGroupComponent, data: { breadcrumbs: true }, }, { path: ':group/:category', component: ProductCategoryComponent, data: { breadcrumbs: true }, }, ] },

I then place <mc-breadcrumbs></mc-breadcrumbs>
within the ProductGroupComponent and in the ProductCategoryComponent because it should only be appearing on those two templates.

Not sure if I have implemented something wrong?

Angular 6 and rxjs 6 support

....
ERROR in ./node_modules/ngx-breadcrumbs/ngx-breadcrumbs/ngx-breadcrumbs.es5.js
Module not found: Error: Can't resolve 'rxjs/BehaviorSubject' in '/Users/marvinheilemann/Documents/Projects/M8FINDER/www/application/client/node_modules/ngx-breadcrumbs/ngx-breadcrumbs'
....

Custom McBreadcrumbsResolver in lazy loading module

I have an app.component registered in app.module. Inside this component i use mc-breadcrumbs component.
i have lazy module 'lazy.module' that has it's own routing configuration. Here i'm using custom breadcrumb resolver inherited from McBreadcrumbsResolver. CustomMcBreadcrumbsResolver added to providers for 'lazy.module'.

With this configuration i see next error:
ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[CustomBreadcrumbsResolver]:

If i add CustomBreadcrumbsResolver to app.module the error is gone and it works as expected.
The problem, that i don't want to add this service to main module(Angular resolvers work in this way).

Angular 7 and RXJS support for new Observable

After upgrading from Angular 5 -> Angular 7, I had to make a manual change in order to get the library to work with the newest version.

Line 4 of ngx-breadcrumbs.es5.js was throwing a console error, which was the only one I couldnt resolve without manually editing the node_modules contents directly.

Before: (not working in Angular 7)
import { BehaviorSubject as BehaviorSubject$1 } from 'rxjs/BehaviorSubject';

After (working in Angular 7):
import { BehaviorSubject as BehaviorSubject$1 } from 'rxjs/Rx';

Home link not displaying as default in front of breadcrumbs

Hi,

I implemented the breadcrumbs in my application, everything is working as expected except I cannot get the Home link to display as default in front of each set of breadcrumbs.

Expected Result
Home / Physical Objects / Details

Actual Result
Physical Objects / Details

Router Config looks like this.

Home Route

export const HOME_ROUTE: Route = {
path: '',
component: HomeComponent,
data: {
pageTitle: 'dx Portal',
breadcrumbs: 'Home'
},
};

Physical Objects Route

export const physicalObjectRoute: Routes = [
{
path: 'physical-object',
data: {
pageTitle: 'Physical Objects',
breadcrumbs: 'Physical Objects'
},
children: [
{
path: '',
component: PhysicalObjectComponent,
},
{
path: ':id',
component: PhysicalObjectDetailComponent,
data: {
pageTitle: 'Physical Objects',
breadcrumbs: 'Details'
},
}
]
}
];

RouterModule.forChild(physicalObjectRoute)

app.routing.module

const LAYOUT_ROUTES = [
HOME_ROUTE,
];

@NgModule({
imports: [
RouterModule.forRoot(LAYOUT_ROUTES, { useHash: true })
],
exports: [
RouterModule
]
})
export class DxPortalAppRoutingModule {}

Templating causes the breadcrumbs to not render

The following will cause the breadcrumbs to not display:

<div *ngIf="someTrueValue">
    <mc-breadcrumbs></mc-breadcrumbs>
</div>

The workaround is to use the hidden attribute:

<div [hidden]="!someTrueValue">
    <mc-breadcrumbs></mc-breadcrumbs>
</div>

I'm guessing the issue lies with the breadcrumbs being within a template but I haven't dug in far enough to know for sure. I've only used the *ngIf but I would guess that the issue would be present within any template.

'mc-breadcrumbs' is not a known element

I added

McBreadcrumbsModule.forRoot(),

to the imports array of app.module.ts,

but it still throws

'mc-breadcrumbs' is not a known element

exception.

why?

Outdated npm library

npm library is outdated (since a year ago)
Please, run ng update to update to Angular ^7.0.0, compile library, and publish it to npmjs ๐Ÿ™

Disabled breadcrumbs

I get breadcrumbs as I expected but as plain text. For example :
/employees/details/35
I wish It would be click-able and links to previous pages. How to do it?

BrowserModule has already been loaded issue only on live dist

Hi,

I have installed ngx-breadcrumbs in my application . it is working fine in development mode. When I build(using "ng build --prod") and run this index.html from that dist folder it is giving "BrowserModule has already been loaded. if you need access to common directives such as ngif and ngfor from a lazy loaded module, import common module instead."

How can I resolve this issue

Thanks

npm version (package.json)

The version number of package.json of this last merge is the same of previous. This new version can't be download by way of npm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.