feat(router): implement redirectTo

This commit is contained in:
vsavkin
2016-06-08 16:14:26 -07:00
parent 25c6a3715d
commit 66caabca0c
8 changed files with 315 additions and 46 deletions

View File

@ -14,6 +14,7 @@ import {Subject} from 'rxjs/Subject';
import {Subscription} from 'rxjs/Subscription';
import {of } from 'rxjs/observable/of';
import {applyRedirects} from './apply_redirects';
import {RouterConfig} from './config';
import {createRouterState} from './create_router_state';
import {createUrlTree} from './create_url_tree';
@ -235,8 +236,14 @@ export class Router {
}
return new Promise((resolvePromise, rejectPromise) => {
let updatedUrl;
let state;
recognize(this.rootComponentType, this.config, url)
applyRedirects(url, this.config)
.mergeMap(u => {
updatedUrl = u;
return recognize(this.rootComponentType, this.config, updatedUrl);
})
.mergeMap((newRouterStateSnapshot) => {
return resolve(this.resolver, newRouterStateSnapshot);
@ -265,7 +272,7 @@ export class Router {
this.currentUrlTree = url;
this.currentRouterState = state;
if (!pop) {
this.location.go(this.urlSerializer.serialize(url));
this.location.go(this.urlSerializer.serialize(updatedUrl));
}
})
.then(