fix(router): properly read and serialize query params
This splits out `path` and `query` into separate params for `location.go` and related methods so that we can handle them properly in both `PathLocationStrategy` and `HashLocationStrategy`. This handles the problem of not reading query params to populate `Location` on the initial page load. Closes #3957 Closes #4225 Closes #3784
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
import {Injectable} from 'angular2/angular2';
|
||||
import {EventListener, History, Location} from 'angular2/src/core/facade/browser';
|
||||
import {LocationStrategy} from './location_strategy';
|
||||
import {LocationStrategy, normalizeQueryParams} from './location_strategy';
|
||||
|
||||
/**
|
||||
* `PathLocationStrategy` is a {@link LocationStrategy} used to configure the
|
||||
@ -67,9 +67,11 @@ export class PathLocationStrategy extends LocationStrategy {
|
||||
|
||||
getBaseHref(): string { return this._baseHref; }
|
||||
|
||||
path(): string { return this._location.pathname; }
|
||||
path(): string { return this._location.pathname + normalizeQueryParams(this._location.search); }
|
||||
|
||||
pushState(state: any, title: string, url: string) { this._history.pushState(state, title, url); }
|
||||
pushState(state: any, title: string, url: string, queryParams: string) {
|
||||
this._history.pushState(state, title, (url + normalizeQueryParams(queryParams)));
|
||||
}
|
||||
|
||||
forward(): void { this._history.forward(); }
|
||||
|
||||
|
Reference in New Issue
Block a user