<ol *ngIf="crumbs.length"
class="breadcrumb">
<li *ngFor="let crumb of crumbs; let last = last"
- [ngClass]="{ 'active': last }"
+ [ngClass]="{ 'active': last && finished }"
class="breadcrumb-item">
<a *ngIf="!last && crumb.path !== null"
[routerLink]="crumb.path">{{ crumb.text }}</a>
*/
import { Component, Injector, OnDestroy } from '@angular/core';
-import { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';
+import { ActivatedRouteSnapshot, NavigationEnd, NavigationStart, Router } from '@angular/router';
import { from, Observable, of, Subscription } from 'rxjs';
import { concat, distinct, filter, first, flatMap, toArray } from 'rxjs/operators';
})
export class BreadcrumbsComponent implements OnDestroy {
crumbs: IBreadcrumb[] = [];
+ /**
+ * Usefull for e2e tests.
+ * This allow us to mark the breadcrumb as pending during the navigation from
+ * one page to another.
+ * This resolves the problem of validating the breadcrumb of a new page and
+ * still get the value from the previous
+ */
+ finished = false;
subscription: Subscription;
private defaultResolver = new BreadcrumbsResolver();
constructor(private router: Router, private injector: Injector) {
+ this.subscription = this.router.events
+ .pipe(filter((x) => x instanceof NavigationStart))
+ .subscribe(() => {
+ this.finished = false;
+ });
+
this.subscription = this.router.events
.pipe(filter((x) => x instanceof NavigationEnd))
.subscribe(() => {
})
)
.subscribe((x) => {
+ this.finished = true;
this.crumbs = x;
});
});