fix(router): routerLinkActive should only set classes after the router has successfully navigated
This commit is contained in:
@ -94,7 +94,7 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
|
||||
ngOnDestroy(): any { this.subscription.unsubscribe(); }
|
||||
|
||||
private update(): void {
|
||||
if (!this.links || !this.linksWithHrefs) return;
|
||||
if (!this.links || !this.linksWithHrefs || !this.router.navigated) return;
|
||||
|
||||
const currentUrlTree = this.router.parseUrl(this.router.url);
|
||||
const isActiveLinks = this.reduceList(currentUrlTree, this.links);
|
||||
|
@ -133,6 +133,13 @@ export class Router {
|
||||
private config: Routes;
|
||||
private configLoader: RouterConfigLoader;
|
||||
|
||||
/**
|
||||
* Indicates if at least one navigation happened.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
navigated: boolean = false;
|
||||
|
||||
/**
|
||||
* Creates the router service.
|
||||
*/
|
||||
@ -385,6 +392,7 @@ export class Router {
|
||||
})
|
||||
.then(
|
||||
() => {
|
||||
this.navigated = true;
|
||||
this.routerEvents.next(
|
||||
new NavigationEnd(id, this.serializeUrl(url), this.serializeUrl(appliedUrl)));
|
||||
resolvePromise(navigationIsSuccessful);
|
||||
|
Reference in New Issue
Block a user