fix(router): do not fire events on 'duplicate' location events

This commit is contained in:
vsavkin
2016-07-12 16:13:16 -07:00
parent 5cf58971f1
commit 0b54e3cf0a
2 changed files with 23 additions and 2 deletions

View File

@ -288,7 +288,14 @@ export class Router {
private setUpLocationChangeListener(): void {
this.locationSubscription = <any>this.location.subscribe((change) => {
return this.scheduleNavigation(this.urlSerializer.parse(change['url']), change['pop']);
const tree = this.urlSerializer.parse(change['url']);
// we fire multiple events for a single URL change
// we should navigate only once
if (this.currentUrlTree.toString() !== tree.toString()) {
return this.scheduleNavigation(tree, change['pop']);
} else {
return null;
}
});
}