Skip to content

Commit

Permalink
fix(Ng2LocationServices): Do not fireAfterUpdate when on server.
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad authored and christopherthielen committed Jun 12, 2017
1 parent 5a65d3c commit 543afcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/location/locationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { LocationStrategy } from '@angular/common';

/** A `LocationServices` that delegates to the Angular LocationStrategy */
export class Ng2LocationServices extends BaseLocationServices {
constructor(router: UIRouter, private _locationStrategy: LocationStrategy) {
super(router, true);
constructor(router: UIRouter, private _locationStrategy: LocationStrategy, isBrowser: boolean) {
super(router, isBrowser);

this._locationStrategy.onPopState((evt) => {
if (evt.type !== 'hashchange') {
this._listener(evt);
Expand Down
7 changes: 4 additions & 3 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@
* @preferred @module ng2
*/
/** */
import { Injector, Provider } from "@angular/core";
import { Injector, Provider, PLATFORM_ID } from "@angular/core";
import { isPlatformBrowser } from "@angular/common";
import {
UIRouter, PathNode, StateRegistry, StateService, TransitionService, UrlMatcherFactory, UrlRouter, ViewService,
UrlService, UIRouterGlobals, services, Resolvable, NATIVE_INJECTOR_TOKEN
UrlService, UIRouterGlobals, services, Resolvable, NATIVE_INJECTOR_TOKEN,
} from "@uirouter/core";
import { UIView, ParentUIViewInject } from "./directives/uiView";
import { ng2ViewsBuilder, Ng2ViewConfig } from "./statebuilders/views";
Expand Down Expand Up @@ -130,7 +131,7 @@ export function uiRouterFactory(locationStrategy: LocationStrategy, rootModules:


// ----------------- Configure for ng2 -------------
router.locationService = new Ng2LocationServices(router, locationStrategy);
router.locationService = new Ng2LocationServices(router, locationStrategy, isPlatformBrowser(injector.get(PLATFORM_ID)));
router.locationConfig = new Ng2LocationConfig(router, locationStrategy);

// Apply ng2 ui-view handling code
Expand Down

0 comments on commit 543afcd

Please sign in to comment.