Skip to content

Commit 543afcd

Browse files
aitboudadchristopherthielen
authored andcommitted
fix(Ng2LocationServices): Do not fireAfterUpdate when on server.
1 parent 5a65d3c commit 543afcd

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/location/locationService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { LocationStrategy } from '@angular/common';
55

66
/** A `LocationServices` that delegates to the Angular LocationStrategy */
77
export class Ng2LocationServices extends BaseLocationServices {
8-
constructor(router: UIRouter, private _locationStrategy: LocationStrategy) {
9-
super(router, true);
10-
8+
constructor(router: UIRouter, private _locationStrategy: LocationStrategy, isBrowser: boolean) {
9+
super(router, isBrowser);
10+
1111
this._locationStrategy.onPopState((evt) => {
1212
if (evt.type !== 'hashchange') {
1313
this._listener(evt);

src/providers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@
8585
* @preferred @module ng2
8686
*/
8787
/** */
88-
import { Injector, Provider } from "@angular/core";
88+
import { Injector, Provider, PLATFORM_ID } from "@angular/core";
89+
import { isPlatformBrowser } from "@angular/common";
8990
import {
9091
UIRouter, PathNode, StateRegistry, StateService, TransitionService, UrlMatcherFactory, UrlRouter, ViewService,
91-
UrlService, UIRouterGlobals, services, Resolvable, NATIVE_INJECTOR_TOKEN
92+
UrlService, UIRouterGlobals, services, Resolvable, NATIVE_INJECTOR_TOKEN,
9293
} from "@uirouter/core";
9394
import { UIView, ParentUIViewInject } from "./directives/uiView";
9495
import { ng2ViewsBuilder, Ng2ViewConfig } from "./statebuilders/views";
@@ -130,7 +131,7 @@ export function uiRouterFactory(locationStrategy: LocationStrategy, rootModules:
130131

131132

132133
// ----------------- Configure for ng2 -------------
133-
router.locationService = new Ng2LocationServices(router, locationStrategy);
134+
router.locationService = new Ng2LocationServices(router, locationStrategy, isPlatformBrowser(injector.get(PLATFORM_ID)));
134135
router.locationConfig = new Ng2LocationConfig(router, locationStrategy);
135136

136137
// Apply ng2 ui-view handling code

0 commit comments

Comments
 (0)