fix(router): add an option to disable initial navigation
This commit is contained in:
@ -262,6 +262,22 @@ export class Router {
|
||||
this.navigateByUrl(this.location.path(true), {replaceUrl: true});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the location change listener
|
||||
*/
|
||||
setUpLocationChangeListener(): void {
|
||||
// Zone.current.wrap is needed because of the issue with RxJS scheduler,
|
||||
// which does not work properly with zone.js in IE and Safari
|
||||
this.locationSubscription = <any>this.location.subscribe(Zone.current.wrap((change: any) => {
|
||||
const tree = this.urlSerializer.parse(change['url']);
|
||||
// we fire multiple events for a single URL change
|
||||
// we should navigate only once
|
||||
return this.currentUrlTree.toString() !== tree.toString() ?
|
||||
this.scheduleNavigation(tree, {skipLocationChange: change['pop'], replaceUrl: true}) :
|
||||
null;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current route state.
|
||||
*/
|
||||
@ -439,19 +455,6 @@ export class Router {
|
||||
(_) => this.runNavigate(url, extras.skipLocationChange, extras.replaceUrl, id));
|
||||
}
|
||||
|
||||
private setUpLocationChangeListener(): void {
|
||||
// Zone.current.wrap is needed because of the issue with RxJS scheduler,
|
||||
// which does not work properly with zone.js in IE and Safari
|
||||
this.locationSubscription = <any>this.location.subscribe(Zone.current.wrap((change: any) => {
|
||||
const tree = this.urlSerializer.parse(change['url']);
|
||||
// we fire multiple events for a single URL change
|
||||
// we should navigate only once
|
||||
return this.currentUrlTree.toString() !== tree.toString() ?
|
||||
this.scheduleNavigation(tree, {skipLocationChange: change['pop'], replaceUrl: true}) :
|
||||
null;
|
||||
}));
|
||||
}
|
||||
|
||||
private runNavigate(
|
||||
url: UrlTree, shouldPreventPushState: boolean, shouldReplaceUrl: boolean,
|
||||
id: number): Promise<boolean> {
|
||||
|
Reference in New Issue
Block a user