Skip to content

Commit 82a3e2e

Browse files
fix(Ng2LocationServices): Ignore duplicated 'hashchange' event in favor of 'popstate' event
Closes #52
1 parent 6820b71 commit 82a3e2e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/location/locationService.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/** @module ng2 */
22
/** */
3-
import { UIRouter, BaseLocationServices, parseUrl } from "ui-router-core";
4-
import { LocationStrategy } from "@angular/common";
3+
import { BaseLocationServices, parseUrl, UIRouter } from 'ui-router-core';
4+
import { LocationStrategy } from '@angular/common';
55

66
/** A `LocationServices` that delegates to the Angular LocationStrategy */
77
export class Ng2LocationServices extends BaseLocationServices {
88
constructor(router: UIRouter, private _locationStrategy: LocationStrategy) {
99
super(router, true);
10-
this._locationStrategy.onPopState(this._listener);
10+
11+
this._locationStrategy.onPopState((evt) => {
12+
if (evt.type !== 'hashchange') {
13+
this._listener(evt);
14+
}
15+
});
1116
}
1217

1318
_get() {

0 commit comments

Comments
 (0)