fix(router): provide a top-level route segment for injection

This commit is contained in:
vsavkin
2016-05-04 14:40:17 -07:00
parent d00b26d941
commit b8136cc26e
6 changed files with 14 additions and 3 deletions

View File

@ -59,7 +59,7 @@ export class RouterLink implements OnDestroy {
@HostBinding() href: string;
@HostBinding('class.router-link-active') isActive: boolean = false;
constructor(@Optional() private _routeSegment: RouteSegment, private _router: Router) {
constructor(private _routeSegment: RouteSegment, private _router: Router) {
// because auxiliary links take existing primary and auxiliary routes into account,
// we need to update the link whenever params or other routes change.
this._subscription =

View File

@ -8,7 +8,6 @@ import {ComponentResolver} from '@angular/core';
import {DEFAULT_OUTLET_NAME} from './constants';
import {reflector} from '@angular/core';
// TODO: vsavkin: recognize should take the old tree and merge it
export function recognize(componentResolver: ComponentResolver, rootComponent: Type,
url: UrlTree): Promise<RouteTree> {
let matched = new _MatchResult(rootComponent, [url.root], {}, rootNode(url).children, []);

View File

@ -1,6 +1,7 @@
import {OpaqueToken, ComponentResolver} from '@angular/core';
import {LocationStrategy, PathLocationStrategy, Location} from '@angular/common';
import {Router, RouterOutletMap} from './router';
import {RouteSegment} from './segments';
import {RouterUrlSerializer, DefaultRouterUrlSerializer} from './router_url_serializer';
import {ApplicationRef} from '@angular/core';
import {BaseException} from '@angular/core';
@ -18,6 +19,7 @@ export const ROUTER_PROVIDERS_COMMON: any[] = /*@ts2dart_const*/[
deps: /*@ts2dart_const*/
[ApplicationRef, ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location],
},
/*@ts2dart_Provider*/ {provide: RouteSegment, useFactory: (r) => r.routeTree.root, deps: [Router]}
];
function routerFactory(app: ApplicationRef, componentResolver: ComponentResolver,