Skip to content

Commit

Permalink
fix(module:breadcrumb): fix auto generate not working in lazy modules (
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell authored and vthinkxie committed Mar 27, 2019
1 parent 15b6724 commit 4260a40
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions components/breadcrumb/nz-breadcrumb.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
TemplateRef,
ViewEncapsulation
} from '@angular/core';
import { ActivatedRoute, NavigationEnd, Params, PRIMARY_OUTLET, Router } from '@angular/router';
import { ActivatedRoute, Params, PRIMARY_OUTLET, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';
import { takeUntil } from 'rxjs/operators';

export const NZ_ROUTE_DATA_BREADCRUMB = 'breadcrumb';

Expand Down Expand Up @@ -60,16 +60,10 @@ export class NzBreadCrumbComponent implements OnInit, OnDestroy {
if (this.nzAutoGenerate) {
try {
const activatedRoute = this.injector.get(ActivatedRoute);
const router = this.injector.get(Router);
router.events
.pipe(
filter(e => e instanceof NavigationEnd),
takeUntil(this.destroy$)
)
.subscribe(() => {
this.breadcrumbs = this.getBreadcrumbs(activatedRoute.root);
this.cd.markForCheck();
});
activatedRoute.url.pipe(takeUntil(this.destroy$)).subscribe(() => {
this.breadcrumbs = this.getBreadcrumbs(activatedRoute.root);
this.cd.markForCheck();
});
} catch (e) {
throw new Error('[NG-ZORRO] You should import RouterModule if you want to use NzAutoGenerate');
}
Expand Down

0 comments on commit 4260a40

Please sign in to comment.