Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add call back for multiple parameters? #76

Open
GlennVanSchil opened this issue Jul 26, 2017 · 0 comments
Open

How to add call back for multiple parameters? #76

GlennVanSchil opened this issue Jul 26, 2017 · 0 comments

Comments

@GlennVanSchil
Copy link

I Have the following routes

/projects/
/projects/:projectId
/projects/:projectId/fields
/projects/:projectId/fields/:fieldId

I've successfully replaced the projectId with a project name in the breadcrumb

Projects / Project Name
Projects / Project Name / Fields
Projects / Project Name / Fields / Field ID

by doing

import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {BreadcrumbService} from 'ng2-breadcrumb/bundles/components/breadcrumbService';

@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.component.html',
  styleUrls: ['./dashboard.component.css'],
  encapsulation: ViewEncapsulation.None,
})
export class DashboardComponent implements OnInit {

  /**
   * Regex for UUID: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
   * @param {BreadcrumbService} breadcrumbService
   */
  constructor(private breadcrumbService: BreadcrumbService) {
    breadcrumbService.addFriendlyNameForRoute('/projects', 'Projects');
    breadcrumbService.addCallbackForRouteRegex('^/projects/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', this.getNameForProject);
    breadcrumbService.addFriendlyNameForRouteRegex('^/projects/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/fields', 'Fields');
  }

  ngOnInit() {
  }

  getNameForProject(projectId: string): string {
    console.log('getNameForProject', projectId);
    return 'Project Name';
  }

}

But I'm unable to replace the fieldId as well. My goal is to create a breadcrumb like this:

Project / Project Name / Fields / Field Name

Do you have any documentation about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant