fix(router): browser back and forward buttons not working correctly.

Closes #8524

Closes #8532
This commit is contained in:
Dimitrios Loukadakis
2016-05-08 04:24:46 +03:00
committed by Misko Hevery
parent 27c25bd0e8
commit 595bcdd1ac
3 changed files with 67 additions and 24 deletions

View File

@ -148,23 +148,25 @@ export class Router {
private _setUpLocationChangeListener(): void {
this._locationSubscription = this._location.subscribe(
(change) => { this._navigate(this._urlSerializer.parse(change['url'])); });
(change) => { this._navigate(this._urlSerializer.parse(change['url']), change['pop']); });
}
private _navigate(url: UrlTree): Promise<void> {
private _navigate(url: UrlTree, pop?: boolean): Promise<void> {
this._urlTree = url;
return recognize(this._componentResolver, this._rootComponentType, url, this._routeTree)
.then(currTree => {
return new _ActivateSegments(currTree, this._routeTree)
.activate(this._routerOutletMap, this._rootComponent)
.then(updated => {
if (updated) {
this._routeTree = currTree;
this._location.go(this._urlSerializer.serialize(this._urlTree));
this._changes.emit(null);
}
});
});
.then(currTree => {
return new _ActivateSegments(currTree, this._routeTree)
.activate(this._routerOutletMap, this._rootComponent)
.then(updated => {
if (updated) {
this._routeTree = currTree;
if (isBlank(pop) || !pop) {
this._location.go(this._urlSerializer.serialize(this._urlTree));
}
this._changes.emit(null);
}
});
});
}
}