Skip to content

Commit

Permalink
fix(module:breadcrumb): fix auto-generated with lazy modules (#5670)
Browse files Browse the repository at this point in the history
close #5613
close #5615
  • Loading branch information
Wendell Hu authored Aug 14, 2020
1 parent f5899ad commit 932d92f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/breadcrumb/breadcrumb.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ export class NzBreadCrumbComponent implements OnInit, OnDestroy {
if (child.outlet === PRIMARY_OUTLET) {
// Only parse components in primary router-outlet (in another word, router-outlet without a specific name).
// Parse this layer and generate a breadcrumb item.
const routeURL: string = child.snapshot.url
const routeUrl: string = child.snapshot.url
.map(segment => segment.path)
.filter(path => path)
.join('/');
const nextUrl = url + `/${routeURL}`;

// Do not change nextUrl if routeUrl is falsy. This happens when it's a route lazy loading other modules.
const nextUrl = !!routeUrl ? url + `/${routeUrl}` : url;
const breadcrumbLabel = this.nzRouteLabelFn(child.snapshot.data[this.nzRouteLabel]);
// If have data, go to generate a breadcrumb for it.
if (routeURL && breadcrumbLabel) {
if (routeUrl && breadcrumbLabel) {
const breadcrumb: BreadcrumbOption = {
label: breadcrumbLabel,
params: child.snapshot.params,
Expand Down

0 comments on commit 932d92f

Please sign in to comment.