diff --git a/nativescript-angular/router/ns-location-strategy.ts b/nativescript-angular/router/ns-location-strategy.ts index 99c3b8a3c..4c0088c8b 100644 --- a/nativescript-angular/router/ns-location-strategy.ts +++ b/nativescript-angular/router/ns-location-strategy.ts @@ -342,7 +342,7 @@ export class NSLocationStrategy extends LocationStrategy { NativeScriptDebug.routerLog('NSLocationStrategy._beginPageNavigation()'); } - this.currentOutlet = this.getOutletByFrame(frame); + this.currentOutlet = this.getOutletByFrame(frame) || this.currentOutlet; const lastState = this.currentOutlet.peekState(); if (lastState) { diff --git a/nativescript-angular/router/ns-router-link-active.ts b/nativescript-angular/router/ns-router-link-active.ts index e9a2fa504..b00a35679 100644 --- a/nativescript-angular/router/ns-router-link-active.ts +++ b/nativescript-angular/router/ns-router-link-active.ts @@ -105,12 +105,12 @@ export class NSRouterLinkActive implements OnChanges, OnDestroy, AfterContentIni const currentUrlTree = this.router.parseUrl(this.router.url); const isActiveLinks = this.reduceList(currentUrlTree, this.links); this.classes.forEach((c) => { - if (isActiveLinks) { - this.renderer.addClass(this.element.nativeElement, c); - } else { - this.renderer.removeClass(this.element.nativeElement, c); - } - }); + if (isActiveLinks) { + this.renderer.addClass(this.element.nativeElement, c); + } else { + this.renderer.removeClass(this.element.nativeElement, c); + } + }); } Promise.resolve(hasActiveLinks).then((active) => (this.active = active)); } diff --git a/nativescript-angular/router/ns-router-link.ts b/nativescript-angular/router/ns-router-link.ts index b380d7178..23aa97bac 100644 --- a/nativescript-angular/router/ns-router-link.ts +++ b/nativescript-angular/router/ns-router-link.ts @@ -52,30 +52,29 @@ export class NSRouterLink { private commands: any[] = []; - constructor(private ngZone: NgZone, private router: Router, private navigator: RouterExtensions, private route: ActivatedRoute, private el: ElementRef) { - } - - ngAfterViewInit() { - this.el.nativeElement.on('tap', () => { - this.ngZone.run(() => { - if (NativeScriptDebug.isLogEnabled()) { - NativeScriptDebug.routerLog(`nsRouterLink.tapped: ${this.commands} ` + `clear: ${this.clearHistory} ` + `transition: ${JSON.stringify(this.pageTransition)} ` + `duration: ${this.pageTransitionDuration}`); - } - - const extras = this.getExtras(); - // this.navigator.navigateByUrl(this.urlTree, extras); - this.navigator.navigate(this.commands, { - ...extras, - relativeTo: this.route, - queryParams: this.queryParams, - fragment: this.fragment, - preserveQueryParams: attrBoolValue(this.preserveQueryParams), - queryParamsHandling: this.queryParamsHandling, - preserveFragment: attrBoolValue(this.preserveFragment), - }); - }); - }); - } + constructor(private ngZone: NgZone, private router: Router, private navigator: RouterExtensions, private route: ActivatedRoute, private el: ElementRef) {} + + ngAfterViewInit() { + this.el.nativeElement.on('tap', () => { + this.ngZone.run(() => { + if (NativeScriptDebug.isLogEnabled()) { + NativeScriptDebug.routerLog(`nsRouterLink.tapped: ${this.commands} ` + `clear: ${this.clearHistory} ` + `transition: ${JSON.stringify(this.pageTransition)} ` + `duration: ${this.pageTransitionDuration}`); + } + + const extras = this.getExtras(); + // this.navigator.navigateByUrl(this.urlTree, extras); + this.navigator.navigate(this.commands, { + ...extras, + relativeTo: this.route, + queryParams: this.queryParams, + fragment: this.fragment, + preserveQueryParams: attrBoolValue(this.preserveQueryParams), + queryParamsHandling: this.queryParamsHandling, + preserveFragment: attrBoolValue(this.preserveFragment), + }); + }); + }); + } @Input('nsRouterLink') set params(data: any[] | string) {