Skip to content

Commit 7ca2ea6

Browse files
author
vakrilov
committed
FIx: Navigating to same url triggers navigation to previous page.
1 parent d4ef85a commit 7ca2ea6

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

nativescript-angular/router/ns-location-strategy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ export class NSLocationStrategy extends LocationStrategy {
5959

6060
if (this.states.length > 0) {
6161
let oldState = this.states.pop();
62-
routerLog(`NSLocationStrategy.replaceState POP state: ${oldState.state}, title: ${oldState.title}, url: ${oldState.url}, queryParams: ${oldState.queryParams}`);
63-
this.callPopState(oldState, true);
62+
routerLog(`NSLocationStrategy.replaceState state poped: ${oldState.state}, title: ${oldState.title}, url: ${oldState.url}, queryParams: ${oldState.queryParams}`);
6463
}
6564

6665
this.pushStateInternal(state, title, url, queryParams);

nativescript-angular/router/ns-router-link.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Directive, HostBinding, HostListener, Input} from '@angular/core';
22
import {LocationStrategy} from '@angular/common';
33
import {Router, ActivatedRoute, UrlTree} from '@angular/router';
4+
import {routerLog} from "../trace";
45

56
/**
67
* The RouterLink directive lets you link to specific parts of your app.
@@ -34,43 +35,25 @@ export class NSRouterLink {
3435
@Input() queryParams: { [k: string]: any };
3536
@Input() fragment: string;
3637

37-
// the url displayed on the anchor element.
38-
// @HostBinding() href: string;
39-
40-
urlTree: UrlTree;
41-
4238
/**
4339
* @internal
4440
*/
45-
constructor(
46-
private router: Router, private route: ActivatedRoute,
47-
private locationStrategy: LocationStrategy) { }
41+
constructor(private router: Router, private route: ActivatedRoute) { }
4842

4943
@Input("nsRouterLink")
5044
set params(data: any[] | string) {
5145
if (Array.isArray(data)) {
52-
this.commands = <any>data;
46+
this.commands = data;
5347
} else {
5448
this.commands = [data];
5549
}
5650
}
5751

58-
ngOnChanges(changes: {}): any { this.updateTargetUrlAndHref(); }
59-
6052
@HostListener("tap")
6153
onTap() {
62-
if (this.urlTree) {
63-
this.router.navigateByUrl(this.urlTree);
64-
}
65-
}
66-
67-
private updateTargetUrlAndHref(): void {
68-
this.urlTree = this.router.createUrlTree(
54+
routerLog("nsRouterLink.tapped: " + this.commands);
55+
this.router.navigate(
6956
this.commands,
7057
{ relativeTo: this.route, queryParams: this.queryParams, fragment: this.fragment });
71-
72-
// if (this.urlTree) {
73-
// this.href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree));
74-
// }
7558
}
7659
}

0 commit comments

Comments
 (0)